Skip to content

Commit f96b516

Browse files
committed
minor #775 Add RST Linter (DOCtor-RST) to the CI config (bocharsky-bw)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- Add RST Linter (DOCtor-RST) to the CI config | Q | A | ------------- | --- | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Tickets | <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT Symfony Docs use it, would be great to reuse it here as well ### TODO - [x] Add more rules Seems it was pretty useful looking at the changes diff :) Commits ------- 4ce9ec7 Add RST Linter (DOCtor-RST) to the CI config
2 parents d8fe5c7 + 4ce9ec7 commit f96b516

File tree

17 files changed

+261
-152
lines changed

17 files changed

+261
-152
lines changed

.doctor-rst.yaml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
rules:
2+
american_english: ~
3+
argument_variable_must_match_type: ~
4+
avoid_repetetive_words: ~
5+
# be_kind_to_newcomers: ~
6+
blank_line_after_anchor: ~
7+
# blank_line_after_colon: ~
8+
blank_line_after_directive: ~
9+
# blank_line_after_filepath_in_code_block: ~
10+
# blank_line_after_filepath_in_php_code_block: ~
11+
# blank_line_after_filepath_in_twig_code_block: ~
12+
# blank_line_after_filepath_in_xml_code_block: ~
13+
# blank_line_after_filepath_in_yaml_code_block: ~
14+
blank_line_before_directive: ~
15+
# composer_dev_option_at_the_end: ~
16+
composer_dev_option_not_at_the_end: ~
17+
correct_code_block_directive_based_on_the_content: ~
18+
deprecated_directive_major_version:
19+
major_version: 2
20+
deprecated_directive_min_version:
21+
min_version: '2.0'
22+
deprecated_directive_should_have_version: ~
23+
ensure_bash_prompt_before_composer_command: ~
24+
ensure_exactly_one_space_before_directive_type: ~
25+
ensure_exactly_one_space_between_link_definition_and_link: ~
26+
ensure_link_definition_contains_valid_url: ~
27+
ensure_order_of_code_blocks_in_configuration_block: ~
28+
extend_abstract_admin: ~
29+
extend_abstract_controller: ~
30+
# extend_controller: ~
31+
extension_xlf_instead_of_xliff: ~
32+
# filename_uses_dashes_only: ~
33+
# filename_uses_underscores_only: ~
34+
final_admin_classes: ~
35+
final_admin_extension_classes: ~
36+
forbidden_directives:
37+
directives:
38+
- '.. index::'
39+
indention: ~
40+
kernel_instead_of_app_kernel: ~
41+
# line_length: ~
42+
lowercase_as_in_use_statements: ~
43+
max_blank_lines:
44+
max: 2
45+
max_colons: ~
46+
no_admin_yaml: ~
47+
no_app_bundle: ~
48+
no_app_console: ~
49+
# no_bash_prompt: ~
50+
no_blank_line_after_filepath_in_code_block: ~
51+
no_blank_line_after_filepath_in_php_code_block: ~
52+
no_blank_line_after_filepath_in_twig_code_block: ~
53+
no_blank_line_after_filepath_in_xml_code_block: ~
54+
no_blank_line_after_filepath_in_yaml_code_block: ~
55+
no_brackets_in_method_directive: ~
56+
no_composer_phar: ~
57+
no_composer_req: ~
58+
no_config_yaml: ~
59+
# no_contraction: ~
60+
no_directive_after_shorthand: ~
61+
no_explicit_use_of_code_block_php: ~
62+
no_inheritdoc_in_code_examples: ~
63+
no_merge_conflict: ~
64+
no_namespace_after_use_statements: ~
65+
no_php_open_tag_in_code_block_php_directive: ~
66+
# no_php_prefix_before_bin_console: ~
67+
# no_php_prefix_before_composer: ~
68+
no_space_before_self_xml_closing_tag: ~
69+
only_backslashes_in_namespace_in_php_code_block: ~
70+
only_backslashes_in_use_statements_in_php_code_block: ~
71+
ordered_use_statements: ~
72+
# php_open_tag_in_code_block_php_directive: ~
73+
php_prefix_before_bin_console: ~
74+
replace_code_block_types: ~
75+
replacement: ~
76+
short_array_syntax: ~
77+
# space_before_self_xml_closing_tag: ~
78+
space_between_label_and_link_in_doc: ~
79+
space_between_label_and_link_in_ref: ~
80+
string_replacement: ~
81+
title_underline_length_must_match_title_length: ~
82+
typo: ~
83+
unused_links: ~
84+
use_deprecated_directive_instead_of_versionadded: ~
85+
use_https_xsd_urls: ~
86+
# use_named_constructor_without_new_keyword_rule: ~
87+
valid_inline_highlighted_namespaces: ~
88+
valid_use_statements: ~
89+
versionadded_directive_major_version:
90+
major_version: 2
91+
versionadded_directive_min_version:
92+
min_version: '2.0'
93+
versionadded_directive_should_have_version: ~
94+
yaml_instead_of_yml_suffix: ~
95+
yarn_dev_option_at_the_end: ~
96+
# yarn_dev_option_not_at_the_end: ~

.github/workflows/doctor-rst.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: RST Linter
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
doctor-rst:
9+
name: DOCtor-RST
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
15+
- name: Create cache dir
16+
run: mkdir .cache
17+
18+
- name: Extract base branch name
19+
run: echo "##[set-output name=branch;]$(echo ${GITHUB_BASE_REF:=${GITHUB_REF##*/}})"
20+
id: extract_base_branch
21+
22+
- name: Cache DOCtor-RST
23+
uses: actions/cache@v3
24+
with:
25+
path: .cache
26+
key: doctor-rst-${{ steps.extract_base_branch.outputs.branch }}
27+
28+
- name: DOCtor-RST
29+
uses: docker://oskarstark/doctor-rst
30+
with:
31+
args: --short --error-format=github --cache-file=/github/workspace/.cache/doctor-rst.cache

.github/workflows/test.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Symfony UX
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
pull_request:
46

57
jobs:
68
coding-style-php:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.doctor-rst.cache
12
.php-cs-fixer.cache
23
node_modules
34
yarn.lock

src/Autocomplete/doc/index.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ To use another route, first declare it:
303303
Then specify this new route on the attribute::
304304

305305
// src/Form/FoodAutocompleteField.php
306-
307306
#[AsEntityAutocompleteField(route: 'ux_entity_autocomplete_admin')]
308307
class FoodAutocompleteField
309308
// ...
@@ -470,7 +469,7 @@ This library comes with a Stimulus controller that can activate
470469
Tom Select on any ``select`` or ``input`` element. This can be used
471470
outside of the Form component. For example:
472471

473-
.. code-block:: twig
472+
.. code-block:: html+twig
474473

475474
<select
476475
name="food"
@@ -481,7 +480,7 @@ That's it! If you want the options to be autocompleted via
481480
Ajax, pass a ``url`` value, which works well if you create
482481
a :ref:`custom autocompleter <custom-autocompleter>`:
483482

484-
.. code-block:: twig
483+
.. code-block:: html+twig
485484

486485
<select
487486
name="food"

src/Chartjs/doc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ All options and data are provided as-is to Chart.js. You can read
7777
Once created in PHP, a chart can be displayed using Twig if installed
7878
(requires `Symfony Webpack Encore`_):
7979

80-
.. code-block:: twig
80+
.. code-block:: html+twig
8181

8282
{{ render_chart(chart) }}
8383

src/Cropperjs/doc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ create a Crop object, and use this object inside a standard form::
3535

3636
// ...
3737
use Symfony\Component\HttpFoundation\Request;
38-
use Symfony\UX\Cropperjs\Form\CropperType;
3938
use Symfony\UX\Cropperjs\Factory\CropperInterface;
39+
use Symfony\UX\Cropperjs\Form\CropperType;
4040

4141
class HomeController extends AbstractController
4242
{

src/Dropzone/doc/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ switching the ``@symfony/ux-dropzone/src/style.css`` autoimport to
8080
}
8181
8282
.. note::
83+
8384
*Note*: you should put the value to ``false`` and not remove the line
8485
so that Symfony Flex won’t try to add the line again in the future.
8586

src/LazyImage/doc/index.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ The default usage of Symfony UX LazyImage is to use its Stimulus
3838
controller to first load a small placeholder image that will then be
3939
replaced by the high-definition version once the page has been rendered:
4040

41-
.. code-block:: twig
41+
.. code-block:: html+twig
4242

4343
<img
4444
src="{{ asset('image/small.png') }}"
@@ -58,7 +58,7 @@ larger image, the ``src`` attribute will change to ``image/large.png``.
5858
There is also support for the ``srcset`` attribute by passing an
5959
``srcset`` value to the controller:
6060

61-
.. code-block:: twig
61+
.. code-block:: html+twig
6262

6363
<img
6464
src="{{ asset('image/small.png') }}"
@@ -81,7 +81,7 @@ Instead of using a generated thumbnail that would exist on your
8181
filesystem, you can use the BlurHash algorithm to create a light,
8282
blurred, data-uri thumbnail of the image:
8383

84-
.. code-block:: twig
84+
.. code-block:: html+twig
8585

8686
<img
8787
src="{{ data_uri_thumbnail('public/image/large.png', 100, 75) }}"
@@ -140,7 +140,7 @@ custom Stimulus controller:
140140
141141
Then in your template, add your controller to the HTML attribute:
142142

143-
.. code-block:: twig
143+
.. code-block:: html+twig
144144

145145
<img
146146
src="{{ data_uri_thumbnail('public/image/large.png', 100, 75) }}"
@@ -158,9 +158,9 @@ Then in your template, add your controller to the HTML attribute:
158158

159159
..
160160
161-
**Note**: be careful to add your controller **before** the LazyImage
162-
controller so that it is executed before and can listen on the
163-
``lazy-image:connect`` event properly.
161+
**Note**: be careful to add your controller **before** the LazyImage
162+
controller so that it is executed before and can listen on the
163+
``lazy-image:connect`` event properly.
164164

165165
Backward Compatibility promise
166166
------------------------------

0 commit comments

Comments
 (0)