Skip to content

Commit

Permalink
Use broken vertical bar as adoc table separator
Browse files Browse the repository at this point in the history
Follow up #11134 (comment).

This PR uses broken vertical bar as adoc table separator.
It specifies `[separator=¦]` for adoc table to prevent broken regexp format.
https://docs.asciidoctor.org/asciidoc/latest/tables/data-format/#escape-the-cell-separator

adoc generation is updated as follows:

```diff
% bundle exec rake update_cops_documentation
(snip)

% git diff
(snip)

@@ -587,12 +603,13 @@ EOS

 === Configurable attributes

+[separator=¦]
 |===
 | Name | Default value | Configurable values

-| ForbiddenDelimiters
-| `(?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))`
-| Array
+¦ ForbiddenDelimiters
+¦ `(?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))`
+¦ Array
 |===

 === References
```
  • Loading branch information
koic authored and bbatsov committed Oct 31, 2022
1 parent 41a8249 commit c4b2bb1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/rubocop/cops_documentation_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,11 @@ def configurable_values(pars, name)
# rubocop:enable Metrics/CyclomaticComplexity,Metrics/MethodLength

def to_table(header, content)
table = ['|===', "| #{header.join(' | ')}\n\n"].join("\n")
# Specify `[separator=¦]` to prevent the regexp `|` is not used as a table separator.
# See: https://docs.asciidoctor.org/asciidoc/latest/tables/data-format/#escape-the-cell-separator
table = ['[separator=¦]', '|===', "| #{header.join(' | ')}\n\n"].join("\n")
marked_contents = content.map do |plain_content|
plain_content.map { |c| "| #{c}" }.join("\n")
plain_content.map { |c| "¦ #{c}" }.join("\n")
end
table << marked_contents.join("\n\n")
table << "\n|===\n"
Expand Down

0 comments on commit c4b2bb1

Please sign in to comment.