@@ -89,11 +89,28 @@ Result:
8989My OS is linux-gnu.
9090```
9191
92+ ** NOTE:** the current working directory depends on you. That is, if you run
93+ ` cd docs && sphinx-build . _build/html && cd - ` , CWD will be ` docs ` , which is
94+ the default setting of < https://readthedocs.org > . So if your code structure is
95+ like
96+
97+ ``` console
98+ $ tree --level 1
99+ .
100+ ├── docs
101+ ├── scripts
102+ ├── src
103+ └── tests
104+ ```
105+
106+ And you want to run ` scripts/*.sh ` , you need ` cd .. ` firstly from ` docs ` to
107+ ` . ` else you have to run ` ../scripts/*.sh ` .
108+
92109### Advanced Usages
93110
94111All 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 ` .
96- Click the hyperlink of title to see the actual example .
112+ similar. Click the hyperlinks of the titles and scripts to see the actual
113+ examples .
97114
98115#### [ Generate API Document] ( https://github.com/Freed-Wu/translate-shell/tree/main/docs/api/translate_shell.md )
99116
@@ -118,28 +135,21 @@ Now
118135
119136````{eval-rst}
120137```{eval-sh}
121- generate-api.md.sh '' -maxdepth 1
138+ cd ..
139+ scripts/generate-api.md.pl src/*/*.py
122140```
123141````
124142`````
125143
126- Where ` scripts/generate-api.md.sh ` is a script which search all python file and
127- replace them from ` src/translate_shell/XXX.py ` to
144+ Where
145+ [ ` scripts/generate-api.md.pl ` ] ( https://github.com/Freed-Wu/translate-shell/blob/main/scripts/generate-api.md.pl )
146+ replaces all ` src/translate_shell/XXX.py ` to
128147
129148``` rst
130149.. automodule:: translate_shell.XXX
131150 :members:
132151```
133152
134- ``` bash
135- #! /usr/bin/env bash
136- # shellcheck disable=SC2086
137- cd " $( dirname " $( dirname " $0 " ) " ) " || exit 1
138- find src/translate_shell/$1 $2 $3 -name ' *.py' |
139- perl -pe' s=src/=.. automodule:: =g;
140- s=\.py$=\n :members:=g;s=/__init__==g;s=/=.=g'
141- ```
142-
143153#### [ Generate TODO Document] ( https://github.com/Freed-Wu/translate-shell/tree/main/docs/misc/todo.md )
144154
145155Before:
@@ -156,26 +166,20 @@ Before:
156166- ...
157167```
158168
159- Now:
169+ Now: (notice ` eval-bash ` because readthedocs uses dash as their default ` $SHELL ` )
160170
161171```` markdown
162172# TODO
163173
164- ```{eval-sh}
165- generate-todo.md.sh
174+ ```{eval-bash}
175+ cd ..
176+ scripts/generate-todo.md.pl src/**/*
166177```
167178````
168179
169- Where ` scripts/generate-todo.md.sh ` searches all ` TODO ` s in code then convert
170- them to correct hyperlinks.
171-
172- ``` sh
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*/ /;
176- s=^=- https://github.com/Freed-Wu/tranlate-shell/tree/main/=g;
177- s=(https://\S+)=<\1>=g;s=^(- \S+)=\1\n=g'
178- ```
180+ Where
181+ [ ` scripts/generate-todo.md.pl ` ] ( https://github.com/Freed-Wu/translate-shell/blob/main/scripts/generate-todo.md.pl )
182+ searches all ` TODO ` s in code then convert them to correct hyperlinks.
179183
180184#### [ Generate Requirements Document] ( https://github.com/Freed-Wu/translate-shell/tree/main/docs/resources/requirements.md )
181185
@@ -199,23 +203,14 @@ Now
199203# Requirements
200204
201205```{eval-sh}
202- generate-requirements.md.sh
206+ cd ..
207+ generate-requirements.md.pl
203208```
204209````
205210
206- Where ` scripts/generate-requirements.md.sh ` searches all ` requirements/*.txt ` s:
207-
208- ``` bash
209- #! /usr/bin/env bash
210- cd " $( dirname " $( dirname " $0 " ) " ) " || exit 1
211- for file in requirements/* .txt ; do
212- filename=" ${file##*/ } "
213- perl -pe' s=^([^#\n]\S*)=- [\1](https://pypi.org/project/\1)=g;
214- s/^#\s*//g;s/^!.*/## ' " ${filename%% .txt} " ' /g' < " $file "
215- done
216- ```
217-
218- And ` requirements/completion.txt ` is:
211+ Where
212+ [ ` scripts/generate-requirements.md.pl ` ] ( https://github.com/Freed-Wu/translate-shell/blob/main/scripts/generate-requirements.md.pl )
213+ searches all ` requirements/*.txt ` s and ` requirements/completion.txt ` is:
219214
220215``` unixconfig
221216#!/usr/bin/env -S pip install -r
0 commit comments