Commit Graph

121 Commits

Author SHA1 Message Date
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 17a4ec1c28.
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 5e2866cc34.
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.

370537de05
3040446cec
5ed618e192
76ebafe594

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
utilum 6f6fe69ea8 We should call methods with `.method_name` not `::method_name`.
Found several instances.

Follow up on 63d530c5e6
2018-02-22 00:54:40 +01:00
Fatos Morina 37cf9b3466 Fix typos and add a few suggestions 2017-11-28 19:27:43 +01:00
Ryuta Kamizono 146b1c2e33 Enable `Style/RedundantReturn` rubocop rule, and fixed a couple more
Follow up of #31004.
2017-11-01 07:32:04 +09:00
Koichi ITO 1f37d846a9 Use frozen string literal in guides/ 2017-08-13 22:04:09 +09:00
Matthew Draper 87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590, reversing
changes made to afb66a5a59.
2017-07-02 02:15:17 +09:30
Kir Shatrov cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
bogdanvlviv 40bdbce191
Define path with __dir__
".. with __dir__ we can restore order in the Universe." - by @fxn

Related to 5b8738c2df
2017-05-23 00:53:51 +03:00
JD Gonzales e37283b52e Old expression caught to many chars resulting in 404. Added minor change to resolve 2017-05-12 22:54:11 -05:00
Rafael França 97f7575fde Merge pull request #28337 from riseshia/patch-1
Fix to use correct path with language on guide
2017-05-03 21:04:03 -07:00
Shia 66cd83d9b9 Use target language's document.yaml [ci skip]
Let me build guide with "ko" language,
    
    Before:
    - It try to use guides/source/documents.yaml
    
    After:
    - It try to use guides/source/ko/documents.yaml
2017-05-04 12:47:05 +09:00
Rafael Mendonça França 0871e5e5c1
Fix all style guides violations
Closes #28382
Closes #28651
2017-04-19 20:13:42 -04:00
Ruy Diaz b5c56090ee Add anchor links to all headers
To allow easy linking at all levels and not just from index
2017-04-01 21:35:20 -07:00
Shia ac00659b1b Fix to use correct path with language on guide 2017-03-08 10:54:06 +09:00
Xavier Noria 771a802c37 refactors and fixes in guides generation [ci skip]
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.
2017-02-12 10:33:50 +01:00
Rafael Mendonça França f04a49b033
Fix rubocop violations 2017-02-09 23:13:41 -03:00
Robin Dupret ea141d62df Automatically link to Ruby files referenced in notes [ci skip]
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]
2017-02-07 21:45:53 +01:00
Robin Dupret 0676d28b22 Automatically inject the current Rails version in API links [ci skip]
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.
2017-02-07 18:56:43 +01:00