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.
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.
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.
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 5e2866cc34.
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
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)
```
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.
* Enable `Lint/UselessAssignment` cop to avoid unused variable warnings
Since we've addressed the warning "assigned but unused variable"
frequently.
370537de053040446cec5ed618e19276ebafe594
And also, I've found the unused args in c1b14ad which raises no warnings
by the cop, it shows the value of the cop.
This commit is not precisely atomic, but the changes have evolved, summary:
* The ENV-based interface has been moved upwards, the generator has now a conventional
initializer.
* RAILS_VERSION is now assumed to be a Git tag. A blank RAILS_VERSION means edge guides.
* In consequence, the EDGE env variable is gone.
* The "local" version is also gone, the current SHA1 is computed for edge guides.
* Assumes guides are generated from a repo checkout (time ago users could
generate them from gems.)
* The WARNINGS flag is gone in consequence, you cannot disable warnings.
* The `api_link` Markdown helper is fixed.
* Docs about usage have one single place: rake guides:help.
* Links in guides have been revised.
To ease reading the "Active Support Core Extensions" guide, let's
automatically link references to Ruby files.
It's also possible to reference other components' files in the even
though it's not used in the guides at the moment.
[Petr Skocik & Robin Dupret]
To make sure that the user won't look at a feature that doesn't
already exist if they are looking at a previous version of the guides,
let's automatically inject the Rails version the guides have been
generated against.