Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Lint docs #7479

Merged
merged 7 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/sphinx.yml
Wirone marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Sphinx

on:
pull_request:
paths:
- "**/*.rst"
push:
paths:
- "**/*.rst"

permissions:
contents: "read"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
sphinx:
name: Sphinx reStructuredText validity
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-sphinx-lint
- name: Install sphinx-lint
run: |
pip install --user sphinx-lint
- name: Check Sphinx document sources
run: |
git ls-files --cached -z -- '*.rst' \
| xargs --null -- python -m sphinxlint --enable all --disable trailing-whitespace --max-line-length 2000
2 changes: 1 addition & 1 deletion doc/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Note that ``exclude`` will work only for directories, so if you need to exclude
Both ``exclude`` and ``notPath`` methods accept only relative paths to the ones defined with the ``in`` method, can be called multiple times and accept string or array of them.

See `Symfony\\Finder <https://symfony.com/doc/current/components/finder.html#location>`_
online documentation for other `Finder` methods.
online documentation for other ``Finder`` methods.

Configuring rules
-----------------
Expand Down
2 changes: 1 addition & 1 deletion doc/cookbook_fixers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Step by step
------------

For this step-by-step, we are going to create a simple fixer that
removes all comments from the code that are preceded by `;` (semicolon).
removes all comments from the code that are preceded by ``;`` (semicolon).

We are calling it ``remove_comments`` (code name), or,
``RemoveCommentsFixer`` (class name).
Expand Down
2 changes: 1 addition & 1 deletion doc/ruleSets/PER-CS1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Rule set ``@PER-CS1.0``
=======================

**This ruleset is deprecated** in favour of `@PER-CS2.0`.
**This ruleset is deprecated** in favour of ``@PER-CS2.0``.

Rules that follow `PER Coding Style 1.0 <https://www.php-fig.org/per/coding-style/>`_.

Expand Down
2 changes: 1 addition & 1 deletion doc/ruleSets/PER-CS1.0Risky.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Rule set ``@PER-CS1.0:risky``
=============================

**This ruleset is deprecated** in favour of `@PER-CS2.0:risky`.
**This ruleset is deprecated** in favour of ``@PER-CS2.0:risky``.

Rules that follow `PER Coding Style 1.0 <https://www.php-fig.org/per/coding-style/>`_. This set contains rules that are risky.

Expand Down
2 changes: 1 addition & 1 deletion doc/rules/whitespace/indentation_type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Example #1
<?php

if (true) {
- echo 'Hello!';
-<TAB>echo 'Hello!';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reStructuredText converts TAB characters to spaces :(
https://cs.symfony.com/doc/rules/whitespace/indentation_type.html 👀

+ echo 'Hello!';
}

Expand Down
6 changes: 3 additions & 3 deletions doc/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ which will use the intersection of the paths from the config file and from the a

php php-cs-fixer.phar fix --path-mode=intersection /path/to/dir

The ``--format`` option for the output format. Supported formats are ``txt`` (default one), ``checkstyle``, ``gitlab``, ``json``, ``junit``and ``xml``.
The ``--format`` option for the output format. Supported formats are ``txt`` (default one), ``checkstyle``, ``gitlab``, ``json``, ``junit`` and ``xml``.

NOTE: the output for the following formats are generated in accordance with schemas

Expand Down Expand Up @@ -96,7 +96,7 @@ Complete configuration for rules can be supplied using a ``json`` formatted stri

php php-cs-fixer.phar fix /path/to/project --rules='{"concat_space": {"spacing": "none"}}'

The ``--dry-run`` flag will run the fixer without making changes to your files (implicitly set when you use `check` command).
The ``--dry-run`` flag will run the fixer without making changes to your files (implicitly set when you use ``check`` command).

The ``--diff`` flag can be used to let the fixer output all the changes it makes in ``udiff`` format.

Expand All @@ -123,7 +123,7 @@ automatically fix anything:

cat foo.php | php php-cs-fixer.phar fix --diff -

Finally, if you don't need BC kept on CLI level, you might use `PHP_CS_FIXER_FUTURE_MODE` to start using options that
Finally, if you don't need BC kept on CLI level, you might use ``PHP_CS_FIXER_FUTURE_MODE`` to start using options that
would be default in next MAJOR release and to forbid using deprecated configuration:

.. code-block:: console
Expand Down
2 changes: 2 additions & 0 deletions src/Documentation/FixerDocumentGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ public function generateFixerDocumentation(FixerInterface $fixer): string
{$fileName}
RST;

$doc = str_replace("\t", '<TAB>', $doc);

return "{$doc}\n";
}

Expand Down
2 changes: 1 addition & 1 deletion src/RuleSet/Sets/PERCS1x0RiskySet.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getRules(): array
public function getDescription(): string
{
return <<<'DESC'
**This ruleset is deprecated** in favour of `@PER-CS2.0:risky`.
**This ruleset is deprecated** in favour of ``@PER-CS2.0:risky``.

Rules that follow `PER Coding Style 1.0 <https://www.php-fig.org/per/coding-style/>`_.
DESC;
Expand Down
2 changes: 1 addition & 1 deletion src/RuleSet/Sets/PERCS1x0Set.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getRules(): array
public function getDescription(): string
{
return <<<'DESC'
**This ruleset is deprecated** in favour of `@PER-CS2.0`.
**This ruleset is deprecated** in favour of ``@PER-CS2.0``.

Rules that follow `PER Coding Style 1.0 <https://www.php-fig.org/per/coding-style/>`_.
DESC;
Expand Down
2 changes: 1 addition & 1 deletion tests/AutoReview/DocumentationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public function testAllReportFormatsAreInUsageDoc(): void
}

$expectedContent = substr($expectedContent, 0, -2);
$expectedContent .= 'and ``'.$lastFormat.'``.';
$expectedContent .= ' and ``'.$lastFormat.'``.';

self::assertStringContainsString($expectedContent, $usage);
}
Expand Down