Commit Graph

46 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
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
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
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
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
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
Fatos Morina
37cf9b3466 Fix typos and add a few suggestions 2017-11-28 19:27:43 +01: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 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
2017-07-02 02:15:17 +09:30
Kir Shatrov
cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +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 Mendonça França
0871e5e5c1
Fix all style guides violations
Closes #28382
Closes #28651
2017-04-19 20:13:42 -04: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
Rafael Mendonça França
fe1f4b2ad5
Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
Rafael Mendonça França
0b4679f192
Fix indentation 2016-10-25 03:16:51 -02:00
Xavier Noria
810dff7c9f RuboCop is 100% green 🎉 2016-09-02 00:43:33 +02:00
Xavier Noria
b326e82dc0 applies remaining conventions across the project 2016-08-06 20:20:22 +02:00
Xavier Noria
6b3719b757 applies new string literal convention in guides
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:21:59 +02:00
Akshay Vishnoi
656ab0dfc9 [ci skip] Fix typo 2015-12-22 03:06:35 +05:30
Vipul A M
5cfaf5a46e - Changed IN to ON in markdown renderer condition
- Changed `IN` to `ON` in all note sentences in guides.
2015-01-14 11:52:13 +05:30
Robin Dupret
0aa18c7d18 Consider html+erb as a valid language for snippets
To highlight ERB snippets, both `erb` and `html+erb` are used as a
language passed to the code block. However, only the former will be
correctly highlighted.
2015-01-03 12:57:29 +01:00
Xavier Noria
6dd4c04b71 removes superfluous regexp group 2014-12-23 23:51:42 +01:00
Xavier Noria
f2bdca3bf9 third test to warn against reading guides in GitHub 2014-12-23 23:24:06 +01:00
Xavier Noria
82180f4ebd second test to warn against reading guides in GitHub 2014-12-23 23:18:51 +01:00
Xavier Noria
5a877d504e proof of concept, need to check in GitHub 2014-12-23 23:00:27 +01:00
Hendy Tanata
71c7fd1013 Uppercase HTML in docs.
[skip ci]
2014-08-08 14:27:05 -07:00
Robin Dupret
ad3628b311 Update Redcarpet to 3.1.2
This version fixes an API breakage between 3.0 and 3.1 ; the header
method's arity should not have changed.

[ci skip]
2014-05-14 19:52:47 +02:00
Nate Berkopec
220528548b Guides: output valid HTML5
[ci skip]
2014-05-05 17:42:04 -04:00
Vipul A M
7ecaa0057c remove unused variable 2013-04-13 13:19:54 +05:30
Carlos Antonio da Silva
9886b88a3b Do not strip code blocks, otherwise we may get misaligned output
[ci skip]
2012-11-07 09:22:14 -02:00
Prem Sichanugrist
1fa5c3b39f Fix footnote format
Markdown has footnote, but Redcarpet doesn't support it.
2012-09-17 15:55:17 -04:00
Prem Sichanugrist
f35187be22 Make sure that styles in NOTE block got converted 2012-09-17 15:54:23 -04:00
Prem Sichanugrist
efa7717b7a 4.0 release note now renders correctly with index 2012-09-17 15:54:21 -04:00
Prem Sichanugrist
544f6bcb90 Start rewriting 4.0 release note into Markdown 2012-09-17 15:54:21 -04:00