Commit Graph

138 Commits

Author SHA1 Message Date
Rafael Mendonça França
be0cb4e8f9
Remove debug require from guides generator 2024-05-10 18:42:55 +00:00
Akhil G Krishnan
61090b1f3f Add rake guides:lint task to raise error on broken anchor links
Co-authored-by: zzak <zzakscott@gmail.com>
2024-05-01 17:29:35 +05:30
zzak
7c7e4c5476
Fix building guides outside ./guides directory
As is the case with the `rake preview_docs` task.

```
Error reading assets/stylesrc/style.scss: Cannot open file.

Error reading assets/stylesrc/highlight.scss: Cannot open file.

Error reading assets/stylesrc/print.scss: Cannot open file.
```
2024-04-24 09:54:30 +09:00
John Athayde
76bb36c4df
Add print styles to Rails guides (#51458)
This updates print CSS to be more inline with the overall style. The sidebar is inlined (same as mobile), and content is 100%. Previous code in the launch from boilerplate has been struck or integrated better.

* Links show in text after the original link text
* Border line around code and copy button are removed
* Print is now generated from SCSS to CSS via the generator that builds the other CSS files

Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
2024-04-18 13:31:43 -03:00
Petrik
56a759a22b Remove example filepaths from code blocks in guides
Some code examples use commented out paths for the path where the code
should be written to. These paths can be ignored in the clipboard when
using the "copy" button.

Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
2024-04-09 17:01:29 +02:00
John Athayde
1e4f12c12c
Guides visual redesign (#51341)
Improve the visual presentation of the Rails Guides, bringing them more inline with the new marketing rubyonrails.org site, as part of a project with the Rails Foundation.

The CSS has been recreated from SCSS files, generated into the final pieces. The stylesrc directory contains those commented source files. The generate task will now process those scss => css files.

Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
2024-03-20 16:50:51 -03:00
Petrik
a720480a0a Improve dom_id uniqueness in guides
All headers in a guide get a unique `dom_id` to make anchor links work.
If a header is already present we would prefix it with the `dom_id` of
the parent node. This would not work for headers without parent nodes.

This commit simplifies the `dom_id` uniqueness by only prepending the
parent node if it exists. This can still result in duplicates at the
same level, but for these we already show a warning:

    *** DUPLICATE ID: 'some_id', please make sure that there are no
    headings with the same name at the same level.

Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
2024-02-08 19:18:58 +01:00
Mike Dalessio
cbc79095c2
Update guides generation to use Nokogiri's HTML5 parser
Note that the most frequent change to the output are:

- attribute values, most often data-clipboard-text. libgumbo
  entity-escapes fewer characters in attribute values than libxml2, and
  wraps them in double-quotes. In particulary `>` and `<` are not
  escaped per the HTML5 spec.
- linebreaks are different for some HTML elements, particularly lists.
2023-06-19 15:38:13 -04:00
Petrik
905ab23705 Use h1 from header for guides title tag [ci-skip]
As the main heading is now a h1, the h1 should be used for the title.
2023-04-20 08:09:41 +02:00
Petrik
4bd199301e Use h1 for guide titles
Currently the guides use the h1 tag for the guides logo instead of the
guides title. As the guides title is more important in describing the
content of a guide, the title should use the h1 instead.
This also move every other heading to a more important heading (h3 becomes h2, etc.).

This change should improve SEO for the guides.
2023-04-18 22:27:03 +02:00
John Hawthorn
1f51d7d441 Revert "Fix guides generator"
This reverts commit 1be5e790eba2b1c069d5f15980a5c8ccdc4aa237.
2023-03-30 13:51:28 -07:00
zzak
1be5e790eb
Fix guides generator
Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>
2023-02-21 13:43:25 +09:00
fatkodima
3158bbb9f6 Update rubocop-performance and enable more performance-related cops 2022-08-26 15:07:11 +03:00
Geon George
56e96d9344 Replaces mobi guide with epub for docs because of discontinued support
Removes kindlerb logic

Adds template for epub generator

Renames the kindle dir to /epub

Adds epub module to generator and replaces kindle

Fixes mimetype

Creates basic epub book

Deletes old kindle module

Adds zip package

Updates rubyzip gem name

Removes now unused gepub gem

Adds the required container file for epubs

Fixes media type

Adds new epub generation logic

Removes all buttons from output html

Refactors and generates valid epub files

Removes frontmatter logic used for kindlegen

Filters out epub files in zip

Updates link to kindle doc on sidebar

Fixes rubocop issues

Adds deprecation warning for the old kindle task

Refactors and cleans up epub module

Cleans up epub code

Cleans up private internal method code style

Removes unnecessary imagemagick check
2022-08-05 00:18:20 +05:30
Jonathan Hefner
23d0cd6f6f Unify LTR / RTL CSS for guides
When `main.css` is updated, it is easy for `main.rtl.css` to be
overlooked (see #45423).

This commit eliminates `main.rtl.css` in favor of a unified approach to
LTR / RTL styling in `main.css`.  To accomplish this, the `<body>`
element is rendered with a [`dir` attribute][] (which has the same
effect as setting the CSS `direction` property), and LTR- / RTL-specific
styles are prefixed with `:where(body[dir="..."])` selectors.  (The
[`:where()` pseudo-class][] ensures that selector specificity is not
changed.)

This change also paves the way for automatic detection and application
of LTR / RTL styles when the [`:dir()` pseudo-class][] gains widespread
browser support.

[`dir` attribute]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir
[`:where()` pseudo-class]: https://developer.mozilla.org/en-US/docs/Web/CSS/:where
[`:dir()` pseudo-class]: https://developer.mozilla.org/en-US/docs/Web/CSS/:dir
2022-06-22 16:42:48 -05:00
John Bampton
d6f47017ad Fix spelling
Change `there're` to `there are`

`there're` is not in the dictionary and we use `there are` in many places

https://www.dictionary.com/misspelling?term=there%27re
2022-03-27 05:19:40 +10:00
Hartley McGuire
8b71dc15ef use DidYouMean for broken link fixes in guides
Ruby 2.7+ includes DidYouMean::SpellChecker, so we can use that for
suggesting corrections for broken links instead of a vendored
Levenshtein algorithm.
2022-03-14 16:35:06 -04:00
Jonathan Hefner
b78966b558 Render copy-to-clipboard text in element attribute [ci-skip]
Rendering copy-to-clipboard text in an invisible element causes
invisible extraneous matches when searching text on the page (e.g. with
Ctrl+F).  Rendering in an element attribute avoids this problem.
2021-07-23 12:52:10 -05:00
Hartley McGuire
a3e5e8d909 use ruby 2.7's filter_map instead of select + map
Related: c3d7794, bbbc861
2021-04-26 17:55:33 -04:00
KapilSachdev
a908d06c85
feat(rubocop): Add Style/RedundantRegexpEscape
- This cop will help in removing unnecessary escaping inside Regexp literals.
2020-12-08 18:57:09 +00:00
Jonathan Hefner
c1c4560001 Fix copy button for IRB code examples [ci-skip]
Previously, all text in an `irb` code fence would be copied.  This
commit causes only lines prefixed by an IRB prompt to be copied.
2020-10-31 16:57:17 -05:00
Petrik
4c258caba2 Add copy button for copying guide code examples [skip ci]
Instead of carefully selecting the code in examples, use a copy button
for copying the code. This uses https://clipboardjs.com/ for copying.

For the bash code examples only line starting with $ prompt are copied.
The $ prompt itself is not copied.
2020-10-01 16:32:43 +02:00
Eugene Kenny
c0ea4321b9 Fix variable name in guides markdown generator
Followup to 17a4ec1c28e0e6c3d91b78ee2f1258b026345f8a.
2020-07-28 10:24:35 +01:00
Gerard (Gerry) Caulfield
17a4ec1c28 Add back support for other syntax highlighting
We recently switched to use Rouge for syntax highlighting in the guides,
but in doing so we dropped support for highlighting the following
syntaxes, which are used in the guides:

apache
diff
json
markdown
nginx
scss
xml

There was also css and the "javascript" alias, but @eugeneius already
addressed these two.

They syntaxes were all being converted to "plaintext". This change allows
all the lexers mentioned above as well as any other lexers available
through Rouge.

We have deliberately decided to not support passing rougue custom lexer
options from the code fences. Instead any lexer options that are needed
can be set by adding an entry to the lexer_language case statement. This
should lead to more consistency in formatting and gives us more control
over what Rogue options are allowed.
2020-07-26 18:27:07 +02:00
Eugene Kenny
ce81714f1c Highlight CSS code snippets in guides
Also fix the language identifier for one JavaScript example.
2020-07-13 01:28:35 +01:00
Petrik
f6bcd1496e Use Rouge for guides code highlighting [ci skip]
Replace javascript highlighting using Prism with the Rouge markdown
highlighter. Uses the github theme.
2020-07-08 09:05:08 +02:00
Ryuta Kamizono
c07dff7227 Auto-correct for delete_prefix/delete_suffix
Follow up to #39409.
2020-06-05 12:40:39 +09:00
Lukas_Skywalker
0589fe4c3a Remove Indexer class from Rails Guide generator
This commit removes the orphaned Indexer class from the Rails Guide
generator. The indexer was removed in 2012 during the move from Textile
to Markdown in commit 5e2866cc3445646d8df049413aa5fbf03fa605ef.
2020-05-13 22:21:35 +02:00
Petrik
2e84228d0e Add missing languages for guides code blocks [ci skip]
Some code examples were missing the language used for code highlighting.
2019-12-17 19:38:45 -05:00
Petrik
ceb54819bd Use prism.js for code highlighting in guides [ci skip]
Replace SyntaxHighlighter with prism.js. SyntaxHighlighter does not seem
to be maintained. Prism.js seems a nice alternative with support for
Ruby, javascript, erb and yaml. Prism.js uses the MIT License.
https://github.com/PrismJS/prism

For bash a customized definition of the bash+shell-session themes is
used with the following comamnds  added commands:
brew, bundle, cat, git, gem, rackup, rake, rails, ruby, rubocop and
  yarn
2019-12-16 19:52:13 +01:00
Ryuta Kamizono
d558febe32 Auto-correct rubocop offences 2019-11-24 09:54:47 +09:00
Takayuki Nakata
a341b06622 Suppress deprecation warning in generating the guide index.html
In generating the guide `index.html`, the warning below happens.

```
$ bundle exec rake guides:generate:html
(snip)
Generating index.html.erb as index.html
DEPRECATION WARNING: render file: should be given the absolute path to
a file
(snip)
```
2019-11-08 09:21:23 +09:00
Akira Matsuda
0196551e60 Use match? where we don't need MatchData 2019-07-29 14:23:10 +09:00
Ryuta Kamizono
c81af6ae72 Enable Layout/EmptyLinesAroundAccessModifier cop
We sometimes say "✂️ newline after `private`" in a code review (e.g.
https://github.com/rails/rails/pull/18546#discussion_r23188776,
https://github.com/rails/rails/pull/34832#discussion_r244847195).

Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style
`EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059).

That cop and enforced style will reduce the our code review cost.
2019-06-13 12:00:45 +09:00
M. Saiqul Haq
75aeac9fdf [ci skip] Fix guides to link to edgeapi if on EDGE env 2019-04-01 12:47:34 +07:00
localhostdotdev
d4710fc538 Fix rails guides generation
Was getting `formats=': Invalid formats: "html"
2019-03-22 18:45:22 +01:00
Vipul A M
bb8fe3701a After https://github.com/rails/rails/pull/35281 and https://github.com/rails/rails/pull/35036 AV warns about not having the compiled container.
Use the suggested with_empty_template_cache to overcome warning
2019-03-12 16:22:22 +05:30
Aaron Patterson
e17fe52e0e
Tighten up the AV::Base constructor
The AV::Base constructor was too complicated, and this commit tightens
up the parameters it will take.  At runtime, AV::Base is most commonly
constructed here:

  94d54fa4ab/actionview/lib/action_view/rendering.rb (L72-L74)

This provides an AV::Renderer instance, a hash of assignments, and a
controller instance.  Since this is the common case for construction, we
should remove logic from the constructor that handles other cases.  This
commit introduces special constructors for those other cases.
Interestingly, most code paths that construct AV::Base "strangely" are
tests.
2019-01-29 15:49:40 -08:00
Ryuta Kamizono
ea65d92f19
Enable Lint/UselessAssignment cop to avoid unused variable warnings (#34904)
* Enable `Lint/UselessAssignment` cop to avoid unused variable warnings

Since we've addressed the warning "assigned but unused variable"
frequently.

370537de05092aeea552146b42042833212a1acc
3040446cece8e7a6d9e29219e636e13f180a1e03
5ed618e192e9788094bd92c51255dda1c4fd0eae
76ebafe594fc23abc3764acc7a3758ca473799e5

And also, I've found the unused args in c1b14ad which raises no warnings
by the cop, it shows the value of the cop.
2019-01-09 18:09:01 +09:00
toshimaru
4b56d60fe7 Add OG tags to layout.html.erb 2019-01-09 13:23:22 +09:00
Yosuke Kabuto
cb343ef672 Use safe nav operator when calling RailsGuides::Generator.new
Use String for direction of RailsGuides::Generator
2018-12-05 12:41:07 +09:00
Alberto Almagro
5020c2e302 Use direction instead of rtl flag.
Improve readability by using `direction` as CSS does.

More info: https://developer.mozilla.org/en-US/docs/Web/CSS/direction
Continues: #34486

[Alberto Almagro + Ufuk Kayserilioglu]
2018-11-22 22:39:13 +01:00
Rafael Mendonça França
c4720a25ed Merge pull request #34486 from tamarr/master
allow right to left styling of docs
2018-11-19 13:20:08 -05:00
tamarr
29e0ed13f5
allow right to left styling of docs (#3)
* adding rtl css main file and logic to use
2018-11-19 18:59:52 +02:00
bogdanvlviv
b5b55fbde8
Wrap custom id of a header attribute into \" in rails guides
Related to https://github.com/rails/rails/pull/33953
2018-10-05 00:57:32 +03:00
wagurano
f92a8bfb94 Fix rails guides markdown.rb and renderer.rb to use custom header id 2018-09-23 19:57:36 +09:00
Ryuta Kamizono
b2c1e29c14 Enable Style/ParenthesesAroundCondition cop
To prevent style check in review like https://github.com/rails/rails/pull/33608#discussion_r211087605.
2018-08-19 08:16:21 +09:00
Bart de Water
eb5fea40a4 Enable Start/EndWith and RegexpMatch cops
In cases where the MatchData object is not used, this provides a speed-up:
https://github.com/JuanitoFatas/fast-ruby/#stringmatch-vs-stringmatch-vs-stringstart_withstringend_with-code-start-code-end
2018-07-28 17:37:17 -04:00
Prathamesh Sonpatki
ecb6ee5948
Cleanup credits related code as it is removed now in PR #32429 2018-04-03 15:19:57 +05:30
Yoshiyuki Hirano
f8d346f9fd Not generate needless files in guides
Not generate needless files:

* _license.html.erb, _welcome.html.erb are partial files.
* layout.html.erb is the layout file.
2018-04-02 18:30:23 +09:00