Skip to content

Commit 6786d07

Browse files
committed
🎨 Format pyproject.toml
Update docs about AUR Add py.typed Add FUNDING.yml Add doq template and regenerate all docstrings Fix bug that scripts/ is not in $PATH
1 parent da2d50f commit 6786d07

File tree

19 files changed

+100
-72
lines changed

19 files changed

+100
-72
lines changed

.github/FUNDING.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
custom:
3+
- "https://user-images.githubusercontent.com/32936898/199681341-1c5cfa61-4411-4b67-b268-7cd87c5867bb.png"
4+
- "https://user-images.githubusercontent.com/32936898/199681363-1094a0be-85ca-49cf-a410-19b3d7965120.png"
5+
- "https://user-images.githubusercontent.com/32936898/199681368-c34c2be7-e0d8-43ea-8c2c-d3e865da6aeb.png"

.readthedocs.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ build:
99
tools:
1010
python: "3"
1111

12-
sphinx:
13-
configuration: docs/conf.py
14-
15-
formats:
16-
- pdf
12+
formats: all
1713

1814
python:
1915
install:

README.md

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ For myst:
6565

6666
````markdown
6767
```{eval-sh}
68-
echo My OS is $OSTYPE
68+
echo My OS is $OSTYPE.
6969
```
7070
````
7171

7272
For rst:
7373

7474
```rst
7575
.. eval-sh::
76-
echo My OS is $OSTYPE
76+
echo My OS is $OSTYPE.
7777
7878
```
7979

@@ -86,12 +86,13 @@ sphinx-build docs docs/_build/html
8686
Result:
8787

8888
```text
89-
My OS is linux-gnu
89+
My OS is linux-gnu.
9090
```
9191

9292
### Advanced Usages
9393

94-
All the following code is myst. The corresponding rst is similar.
94+
All of the following examples are myst. The corresponding examples of rst are
95+
similar. Remember to add `scripts` to your `$PATH` in `docs/conf.py`.
9596
Click the hyperlink of title to see the actual example.
9697

9798
#### [Generate API Document](https://github.com/Freed-Wu/translate-shell/tree/main/docs/api/translate_shell.md)
@@ -117,23 +118,24 @@ Now
117118

118119
````{eval-rst}
119120
```{eval-sh}
120-
scripts/generate-api.md.sh '' -maxdepth 1
121+
generate-api.md.sh '' -maxdepth 1
121122
```
122123
````
123124
`````
124125

125126
Where `scripts/generate-api.md.sh` is a script which search all python file and
126-
replace them from `src/translate_shell/X/Y/Z.py` to
127+
replace them from `src/translate_shell/XXX.py` to
127128

128129
```rst
129-
.. automodule:: translate_shell.X.Y.Z`
130+
.. automodule:: translate_shell.XXX
130131
:members:
131132
```
132133

133134
```bash
134135
#!/usr/bin/env bash
135136
# shellcheck disable=SC2086
136-
find src/sphinxcontrib/eval/$1 $2 $3 -name '*.py' |
137+
cd "$(dirname "$(dirname "$0")")" || exit 1
138+
find src/translate_shell/$1 $2 $3 -name '*.py' |
137139
perl -pe's=src/=.. automodule:: =g;
138140
s=\.py$=\n :members:=g;s=/__init__==g;s=/=.=g'
139141
```
@@ -142,38 +144,40 @@ s=\.py$=\n :members:=g;s=/__init__==g;s=/=.=g'
142144

143145
Before:
144146

145-
<!-- markdownlint-disable MD013-->
146-
147147
```markdown
148148
# TODO
149149

150-
- <https://github.com/Freed-Wu/tranlate-shell/tree/main/src/translate_shell/translators/stardict/__init__.py#L4> more stardicts.
151-
- <https://github.com/Freed-Wu/tranlate-shell/tree/main/src/translate_shell/translators/stardict/__init__.py#L5> Create different subclasses for different dict to get phonetic, explains
152-
- <https://github.com/Freed-Wu/tranlate-shell/tree/main/src/translate_shell/ui/repl.py#L33> make the last line gray like ptpython
153-
...
150+
- <https://github.com/Freed-Wu/tranlate-shell/tree/main/src/translate_shell/translators/stardict/__init__.py#L4>
151+
more stardicts.
152+
- <https://github.com/Freed-Wu/tranlate-shell/tree/main/src/translate_shell/translators/stardict/__init__.py#L5>
153+
Create different subclasses for different dict to get phonetic, explains
154+
- <https://github.com/Freed-Wu/tranlate-shell/tree/main/src/translate_shell/ui/repl.py#L33>
155+
make the last line gray like ptpython
156+
- ...
154157
```
155158

156-
<!-- markdownlint-enable MD013-->
157-
158159
Now:
159160

160161
````markdown
161162
# TODO
162163

163164
```{eval-sh}
164-
scripts/generate-todo.md.sh
165+
generate-todo.md.sh
165166
```
166167
````
167168

168-
Where the script searches all `TODO`s in code then convert them to correct hyperlinks.
169+
Where `scripts/generate-todo.md.sh` searches all `TODO`s in code then convert
170+
them to correct hyperlinks.
169171

170172
```sh
171-
grep -RIn TODO: src | perl -pe's/:/#L/;s/:\s*#?\s*TODO:\s*/ /;
173+
#!/usr/bin/env bash
174+
cd "$(dirname "$(dirname "$0")")" || exit 1
175+
grep -RIn TODO: src | perl -pe's/:/#L/;s/:\s*#?\s*TODO:\s*/ /;
172176
s=^=- https://github.com/Freed-Wu/tranlate-shell/tree/main/=g;
173-
s=(https://\S+)=<\1>=g'
177+
s=(https://\S+)=<\1>=g;s=^(- \S+)=\1\n=g'
174178
```
175179

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

178182
Before:
179183

@@ -195,22 +199,23 @@ Now
195199
# Requirements
196200

197201
```{eval-sh}
198-
scripts/generate-requirements.md.sh
202+
generate-requirements.md.sh
199203
```
200204
````
201205

202-
Where
206+
Where `scripts/generate-requirements.md.sh` searches all `requirements/*.txt`s:
203207

204208
```bash
205209
#!/usr/bin/env bash
206-
for file in requirements.txt requirements/*.txt ; do
210+
cd "$(dirname "$(dirname "$0")")" || exit 1
211+
for file in requirements/*.txt ; do
207212
filename="${file##*/}"
208213
perl -pe's=^([^#\n]\S*)=- [\1](https://pypi.org/project/\1)=g;
209214
s/^#\s*//g;s/^!.*/## '"${filename%%.txt}"'/g' < "$file"
210215
done
211216
```
212217

213-
And `requirements/completion.txt`:
218+
And `requirements/completion.txt` is:
214219

215220
```unixconfig
216221
#!/usr/bin/env -S pip install -r

docs/api/eval.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
````{eval-rst}
44
```{eval-sh}
5-
scripts/generate-api.md.sh
5+
generate-api.md.sh
66
```
77
````

docs/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
except ImportError:
1313
import tomli as tomllib
1414

15+
scriptdir = os.path.join(os.path.dirname(os.path.dirname(__file__)), "scripts")
16+
os.environ["PATH"] = scriptdir + os.path.pathsep + os.getenv("PATH", "")
17+
1518
# -- Path setup --------------------------------------------------------------
1619

1720
# If extensions (or modules to document with autodoc) are in another directory,

docs/resources/install.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ pip install sphinxcontrib-eval
1010
pip uninstall sphinxcontrib-eval
1111
```
1212

13-
## AUR
13+
## [AUR](https://aur.archlinux.org/packages/python-sphinxcontrib-eval)
1414

15-
Not yet.
15+
```sh
16+
yay -S python-sphinxcontrib-eval
17+
```
18+
19+
```sh
20+
sudo pacman -R python-sphinxcontrib-eval
21+
```

docs/resources/requirements.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Requirements
22

33
```{eval-sh}
4-
scripts/generate-requirements.md.sh
4+
generate-requirements.md.sh
55
```

pyproject.toml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ Source = "https://github.com/Freed-Wu/sphinxcontrib-eval"
3737
[tool.setuptools_scm]
3838
write_to = "src/sphinxcontrib/eval/_version.py"
3939

40+
[tool.setuptools.package-data]
41+
"sphinxcontrib.eval" = ["py.typed"]
42+
4043
[tool.setuptools.dynamic]
4144
dependencies = { file = "requirements.txt" }
4245

@@ -55,19 +58,14 @@ profile = "black"
5558
[tool.pydocstyle]
5659
add_ignore = "D205, D400"
5760

61+
[tool.doq]
62+
template_path = "templates"
63+
5864
[tool.bandit]
59-
skips = [
60-
"B404",
61-
]
65+
skips = ["B404"]
6266

6367
[tool.bandit.assert_used]
64-
skips = [
65-
"tests/*.py",
66-
"*_test.py",
67-
"test_*.py",
68-
]
68+
skips = ["tests/*.py", "*_test.py", "test_*.py"]
6969

7070
[tool.coverage.report]
71-
exclude_lines = [
72-
"if TYPE_CHECKING:"
73-
]
71+
exclude_lines = ["if TYPE_CHECKING:", "if __name__ == .__main__.:"]

scripts/generate-api.md.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env bash
22
# shellcheck disable=SC2086
3+
cd "$(dirname "$(dirname "$0")")" || exit 1
34
find src/sphinxcontrib/eval/$1 $2 $3 -name '*.py' |
45
perl -pe's=src/=.. automodule:: =g;
56
s=\.py$=\n :members:=g;s=/__init__==g;s=/=.=g'

scripts/generate-requirements.md.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bash
2+
cd "$(dirname "$(dirname "$0")")" || exit 1
23
for file in requirements.txt requirements/*.txt; do
34
filename="${file##*/}"
45
perl -pe's=^([^#\n]\S*)=- [\1](https://pypi.org/project/\1)=g;

0 commit comments

Comments
 (0)