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