| 1 |
# spell-checker:ignore libsystemd libattr libcap gsub |
| 2 |
|
| 3 |
name: Check uudoc Documentation Generation |
| 4 |
|
| 5 |
on: |
| 6 |
pull_request: |
| 7 |
paths: |
| 8 |
- 'src/bin/uudoc.rs' |
| 9 |
- 'src/uu/*/locales/en-US.ftl' |
| 10 |
- 'Cargo.toml' |
| 11 |
- '.github/workflows/documentation.yml' |
| 12 |
push: |
| 13 |
branches: |
| 14 |
- main |
| 15 |
paths: |
| 16 |
- 'src/bin/uudoc.rs' |
| 17 |
- 'src/uu/*/locales/en-US.ftl' |
| 18 |
- 'Cargo.toml' |
| 19 |
|
| 20 |
permissions: |
| 21 |
contents: read |
| 22 |
|
| 23 |
jobs: |
| 24 |
check-doc: |
| 25 |
name: Verify uudoc generates correct documentation |
| 26 |
runs-on: ubuntu-latest |
| 27 |
|
| 28 |
steps: |
| 29 |
- name: Checkout repository |
| 30 |
uses: actions/[email protected] |
| 31 |
with: |
| 32 |
persist-credentials: false |
| 33 |
|
| 34 |
- name: Install/setup prerequisites |
| 35 |
shell: bash |
| 36 |
run: sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev libsystemd-dev libacl1-dev libattr1-dev libcap-dev |
| 37 |
|
| 38 |
- name: Download tldr |
| 39 |
run: curl -L https://github.com/tldr-pages/tldr/releases/latest/download/tldr.zip -o docs/tldr.zip |
| 40 |
|
| 41 |
- name: Generate documentation |
| 42 |
run: cargo run --bin uudoc --all-features |
| 43 |
|
| 44 |
- name: Get current version from Cargo.toml |
| 45 |
id: version |
| 46 |
run: | |
| 47 |
VERSION=$(awk '/\[workspace\.package\]/{flag=1; next} flag && /^version = /{gsub(/.*= "/, ""); gsub(/".*/, ""); print; exit}' Cargo.toml) |
| 48 |
echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 49 |
echo "Detected version: $VERSION" |
| 50 |
|
| 51 |
- name: Check for --repeated option in uniq.md |
| 52 |
run: | |
| 53 |
if [ ! -f "docs/src/utils/uniq.md" ]; then |
| 54 |
echo "docs/src/utils/uniq.md does not exist" |
| 55 |
exit 1 |
| 56 |
fi |
| 57 |
|
| 58 |
if ! grep -q -- "--repeated" docs/src/utils/uniq.md; then |
| 59 |
echo "'--repeated' option not found in docs/src/utils/uniq.md" |
| 60 |
echo "Content of uniq.md:" |
| 61 |
head -50 docs/src/utils/uniq.md |
| 62 |
exit 1 |
| 63 |
fi |
| 64 |
|
| 65 |
- name: Check for correct version in ls.md |
| 66 |
run: | |
| 67 |
VERSION="${{ steps.version.outputs.version }}" |
| 68 |
|
| 69 |
if [ ! -f "docs/src/utils/ls.md" ]; then |
| 70 |
echo "docs/src/utils/ls.md does not exist" |
| 71 |
exit 1 |
| 72 |
fi |
| 73 |
|
| 74 |
if ! grep -q "v(uutils coreutils) $VERSION" docs/src/utils/ls.md; then |
| 75 |
echo "Version '$VERSION' not found in docs/src/utils/ls.md" |
| 76 |
echo "Found version info:" |
| 77 |
grep "v(uutils coreutils)" docs/src/utils/ls.md || echo "No version info found" |
| 78 |
echo "Full version section:" |
| 79 |
grep -A2 -B2 "version" docs/src/utils/ls.md || echo "No version section found" |
| 80 |
exit 1 |
| 81 |
fi |
| 82 |
|
| 83 |
- name: Verify usage information is present |
| 84 |
run: | |
| 85 |
if [ ! -f "docs/src/utils/cat.md" ]; then |
| 86 |
echo "docs/src/utils/cat.md does not exist" |
| 87 |
exit 1 |
| 88 |
fi |
| 89 |
|
| 90 |
if ! grep -q "cat \[OPTION\].*\[FILE\]" docs/src/utils/cat.md; then |
| 91 |
echo "Usage information missing from cat.md" |
| 92 |
echo "Content around usage:" |
| 93 |
grep -A5 -B5 "cat" docs/src/utils/cat.md | head -20 |
| 94 |
exit 1 |
| 95 |
fi |
| 96 |
|
| 97 |
- name: Verify help text is properly resolved |
| 98 |
run: | |
| 99 |
if [ ! -f "docs/src/utils/cat.md" ]; then |
| 100 |
echo "docs/src/utils/cat.md does not exist" |
| 101 |
exit 1 |
| 102 |
fi |
| 103 |
|
| 104 |
if grep -q "cat-help-" docs/src/utils/cat.md; then |
| 105 |
echo "Found unresolved Fluent keys in cat.md - help text not properly translated" |
| 106 |
echo "Unresolved Fluent keys found:" |
| 107 |
grep "cat-help-" docs/src/utils/cat.md |
| 108 |
exit 1 |
| 109 |
fi |
| 110 |
|
| 111 |
- name: Verify about text is present |
| 112 |
run: | |
| 113 |
if [ ! -f "docs/src/utils/cat.md" ]; then |
| 114 |
echo "docs/src/utils/cat.md does not exist" |
| 115 |
exit 1 |
| 116 |
fi |
| 117 |
|
| 118 |
if ! grep -q "Concatenate FILE(s)" docs/src/utils/cat.md; then |
| 119 |
echo "About text missing from cat.md" |
| 120 |
echo "Content of cat.md:" |
| 121 |
head -30 docs/src/utils/cat.md |
| 122 |
exit 1 |
| 123 |
fi |
| 124 |
|
| 125 |
- name: Verify tldr examples integration |
| 126 |
run: | |
| 127 |
if [ ! -f "docs/src/utils/cp.md" ]; then |
| 128 |
echo "docs/src/utils/cp.md does not exist" |
| 129 |
exit 1 |
| 130 |
fi |
| 131 |
|
| 132 |
if ! grep -q "The examples are provided by" docs/src/utils/cp.md; then |
| 133 |
echo "tldr examples integration missing from cp.md" |
| 134 |
echo "Expected to find 'The examples are provided by' text" |
| 135 |
echo "Content of cp.md:" |
| 136 |
tail -20 docs/src/utils/cp.md |
| 137 |
exit 1 |
| 138 |
fi |