Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions .github/workflows/check-whitespace.yml

This file was deleted.

107 changes: 107 additions & 0 deletions .github/workflows/docbook-cs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# https://docs.github.com/en/actions

name: "DocBook Lint"

on:
push:
pull_request:
branches:
- "master"

permissions:
contents: "read"

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

jobs:
docbook-cs:
name: "DocBook Style Check"
runs-on: "ubuntu-latest"

env:
# Base commit to diff against: PR base on pull_request, pre-push tip on push.
BASE_SHA: |-
${{
case(
github.event_name == 'pull_request', github.event.pull_request.base.sha,
github.event_name == 'push', github.event.before,
'INVALID'
)
}}

strategy:
matrix:
language:
- "en"

steps:
- name: "Checkout php/doc-${{ matrix.language }}"
uses: "actions/checkout@v6"
with:
ref: "${{ github.event.pull_request.head.sha }}"
path: "${{ matrix.language }}"
fetch-depth: 50

- name: "Checkout php/doc-base"
uses: "actions/checkout@v6"
with:
path: "doc-base"
repository: "php/doc-base"

- name: "Checkout php/docbook-cs"
uses: "actions/checkout@v6"
with:
path: "docbook-cs"
repository: "php/docbook-cs"

- name: "Fetch diff base"
working-directory: "${{ matrix.language }}"
run: |
git fetch origin "$BASE_SHA" --depth=50
# Deepen until the merge-base is reachable (long-lived branches)
for i in 1 2 3 4 5; do
git merge-base "$BASE_SHA" HEAD >/dev/null 2>&1 && break
git fetch --deepen=100 origin "$BASE_SHA"
done

- name: "Setup PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.5"
extensions: "dom, libxml, simplexml"
tools: composer, cs2pr

- name: "Build documentation"
run: |
php doc-base/configure.php \
--disable-libxml-check \
--enable-xml-details \
--redirect-stderr-to-stdout \
--with-lang=${{ matrix.language }}

- name: "Install docbook-cs"
working-directory: "docbook-cs"
run: composer install --no-interaction --no-progress

- name: "Run docbook-cs with diff"
working-directory: "${{ matrix.language }}"
run: |
set -o pipefail
git diff "$BASE_SHA"...HEAD | php ../docbook-cs/bin/docbook-cs \
--report=checkstyle \
--diff \
--no-colors > docbook-report.xml

- name: "Upload report"
if: ${{ ! cancelled() }}
uses: "actions/upload-artifact@v7"
with:
name: "docbook-report"
path: "${{ matrix.language }}/docbook-report.xml"

- name: "Annotate PR with violations"
if: ${{ ! cancelled() }}
working-directory: "${{ matrix.language }}"
run: cs2pr docbook-report.xml --colorize --prepend-filename
37 changes: 37 additions & 0 deletions docbookcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<docbookcs xmlns="https://php.github.io/docbook-cs/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://php.github.io/docbook-cs/config
https://php.github.io/docbook-cs/config.xsd">

<project>
<directory alias="doc-en">en</directory>
<directory>doc-base</directory>
</project>

<sniffs>
<sniff class="DocbookCS\Sniff\SimparaSniff" />
<sniff class="DocbookCS\Sniff\ExceptionNameSniff" />
<sniff class="DocbookCS\Sniff\AttributeOrderSniff" />
<sniff class="DocbookCS\Sniff\WhitespaceSniff" />
</sniffs>

<paths>
<path>.</path>
</paths>

<entities>
<file>contributors.ent</file>
<file>extensions.ent</file>
<file>language-defs.ent</file>
<file>language-snippets.ent</file>
<directory>../doc-base/entities/</directory>
<file>../doc-base/temp/file-entities.ent</file>
<directory>../doc-base/temp/file-entities</directory>
</entities>

<exclude>
<pattern>output/*</pattern>
</exclude>

</docbookcs>
9 changes: 9 additions & 0 deletions reference/mbstring/functions/mb-detect-encoding.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
bytes form a valid string. If the input string contains such a sequence, that
encoding will be rejected.
</para>
<para>

Check failure on line 36 in reference/mbstring/functions/mb-detect-encoding.xml

View workflow job for this annotation

GitHub Actions / DocBook Style Check (en)

mb-detect-encoding.xml: <para> contains only inline content and should be <simpara>.
This should fail
</para>
<simpara>
This shouldn't fail
</simpara>
<para>

Check failure on line 42 in reference/mbstring/functions/mb-detect-encoding.xml

View workflow job for this annotation

GitHub Actions / DocBook Style Check (en)

mb-detect-encoding.xml: <para> contains only inline content and should be <simpara>.
In the push rule, this should fail. But the first one shouldn't
</para>

<warning>
<title>The result is not accurate</title>
Expand Down
Loading