Skip to content

Commit

Permalink
📝 Add documents about sphinxcontrib-requirements-txt
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Sep 2, 2023
1 parent 6a7ee60 commit 4093604
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
26 changes: 14 additions & 12 deletions .pre-commit-config.yaml
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env -S pre-commit run -ac
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -23,11 +22,11 @@ repos:
- id: check-toml
- id: check-json
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.4.2
rev: v1.5.4
hooks:
- id: remove-crlf
- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
rev: v2.2.5
hooks:
- id: codespell
additional_dependencies:
Expand All @@ -39,24 +38,27 @@ repos:
args:
- --msg-filename
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: 2.7.1
rev: 2.7.2
hooks:
- id: editorconfig-checker
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: check-mailmap
- repo: https://github.com/rhysd/actionlint
rev: v1.6.25
hooks:
- id: actionlint
- repo: https://github.com/adrienverge/yamllint
rev: v1.30.0
rev: v1.32.0
hooks:
- id: yamllint
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
hooks:
- id: mdformat
args:
- --number
additional_dependencies:
- mdformat-pyproject
- mdformat-gfm
- mdformat-myst
- mdformat-toc
Expand All @@ -65,22 +67,22 @@ repos:
- mdformat-black
- mdformat-config
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.6.0
rev: v0.8.1
hooks:
- id: markdownlint-cli2
additional_dependencies:
- [email protected]
- repo: https://github.com/Freed-Wu/pre-commit-hooks
rev: 0.0.10
rev: 0.0.11
hooks:
- id: update-CITATION.cff
- id: update-pyproject.toml
- repo: https://github.com/perltidy/perltidy
rev: "20230309.02"
rev: "20230701.02"
hooks:
- id: perltidy
- repo: https://github.com/psf/black
rev: 23.1.0
rev: 23.7.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
Expand All @@ -94,7 +96,7 @@ repos:
additional_dependencies:
- tomli
- repo: https://github.com/kumaraditya303/mirrors-pyright
rev: v1.1.300
rev: v1.1.322
hooks:
- id: pyright
- repo: https://github.com/PyCQA/bandit
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ scripts/generate-api.md.pl src/*/*.py
`````

Where
[`scripts/generate-api.md.pl`](https://github.com/Freed-Wu/translate-shell/blob/main/scripts/generate-api.md.pl)
[`scripts/generate-api.md.pl`](https://github.com/sphinx-contrib/eval/blob/main/scripts/generate-api.md.pl)
replaces all `src/translate_shell/XXX.py`s to

```rst
Expand Down Expand Up @@ -184,6 +184,9 @@ searches all `TODO`s in code then convert them to correct hyperlinks.

#### [Generate Requirements Document](https://github.com/Freed-Wu/translate-shell/tree/main/docs/resources/requirements.md)

**Note**: A more "sphinx" solution is
[sphinxcontrib-requirements-txt](https://github.com/sphinx-contrib/requirements-txt).

Before:

```markdown
Expand All @@ -210,7 +213,7 @@ generate-requirements.md.pl
````

Where
[`scripts/generate-requirements.md.pl`](https://github.com/Freed-Wu/translate-shell/blob/main/scripts/generate-requirements.md.pl)
[`scripts/generate-requirements.md.pl`](https://github.com/sphinx-contrib/eval/blob/main/scripts/generate-requirements.md.pl)
searches all `requirements/*.txt`s and `requirements/completion.txt` is:

```unixconfig
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ file = "requirements/dev.txt"
file = "requirements/myst.txt"
# end: scripts/update-pyproject.toml.pl

[tool.mdformat]
number = true

[tool.black]
line-length = 79

Expand Down
10 changes: 10 additions & 0 deletions scripts/generate-requirements.md.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env -S perl -p
$title = $ARGV;
$title =~ s=.*?requirements/(.*?)\.txt=$1=;
if (m(^[^#].*://)) {
s=(^.*://)(.*)=- [$1$2](https://$2)=;
next;
}
s`^([^#\n][^\s[>=<^!^]*)`- [$1](https://pypi.org/project/$1)`;
s/^#\s*//;
s/^!.*/## $title/;

0 comments on commit 4093604

Please sign in to comment.