@@ -65,15 +65,15 @@ For myst:
65
65
66
66
```` markdown
67
67
```{eval-sh}
68
- echo My OS is $OSTYPE
68
+ echo My OS is $OSTYPE.
69
69
```
70
70
````
71
71
72
72
For rst:
73
73
74
74
``` rst
75
75
.. eval-sh::
76
- echo My OS is $OSTYPE
76
+ echo My OS is $OSTYPE.
77
77
78
78
```
79
79
@@ -86,12 +86,13 @@ sphinx-build docs docs/_build/html
86
86
Result:
87
87
88
88
``` text
89
- My OS is linux-gnu
89
+ My OS is linux-gnu.
90
90
```
91
91
92
92
### Advanced Usages
93
93
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 ` .
95
96
Click the hyperlink of title to see the actual example.
96
97
97
98
#### [ Generate API Document] ( https://github.com/Freed-Wu/translate-shell/tree/main/docs/api/translate_shell.md )
@@ -117,23 +118,24 @@ Now
117
118
118
119
````{eval-rst}
119
120
```{eval-sh}
120
- scripts/ generate-api.md.sh '' -maxdepth 1
121
+ generate-api.md.sh '' -maxdepth 1
121
122
```
122
123
````
123
124
`````
124
125
125
126
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
127
128
128
129
``` rst
129
- .. automodule:: translate_shell.X.Y.Z`
130
+ .. automodule:: translate_shell.XXX
130
131
:members:
131
132
```
132
133
133
134
``` bash
134
135
#! /usr/bin/env bash
135
136
# 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' |
137
139
perl -pe' s=src/=.. automodule:: =g;
138
140
s=\.py$=\n :members:=g;s=/__init__==g;s=/=.=g'
139
141
```
@@ -142,38 +144,40 @@ s=\.py$=\n :members:=g;s=/__init__==g;s=/=.=g'
142
144
143
145
Before:
144
146
145
- <!-- markdownlint-disable MD013-->
146
-
147
147
``` markdown
148
148
# TODO
149
149
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
+ - ...
154
157
```
155
158
156
- <!-- markdownlint-enable MD013-->
157
-
158
159
Now:
159
160
160
161
```` markdown
161
162
# TODO
162
163
163
164
```{eval-sh}
164
- scripts/ generate-todo.md.sh
165
+ generate-todo.md.sh
165
166
```
166
167
````
167
168
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.
169
171
170
172
``` 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*/ /;
172
176
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 '
174
178
```
175
179
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 )
177
181
178
182
Before:
179
183
@@ -195,22 +199,23 @@ Now
195
199
# Requirements
196
200
197
201
```{eval-sh}
198
- scripts/ generate-requirements.md.sh
202
+ generate-requirements.md.sh
199
203
```
200
204
````
201
205
202
- Where
206
+ Where ` scripts/generate-requirements.md.sh ` searches all ` requirements/*.txt ` s:
203
207
204
208
``` bash
205
209
#! /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
207
212
filename=" ${file##*/ } "
208
213
perl -pe' s=^([^#\n]\S*)=- [\1](https://pypi.org/project/\1)=g;
209
214
s/^#\s*//g;s/^!.*/## ' " ${filename%% .txt} " ' /g' < " $file "
210
215
done
211
216
```
212
217
213
- And ` requirements/completion.txt ` :
218
+ And ` requirements/completion.txt ` is :
214
219
215
220
``` unixconfig
216
221
#!/usr/bin/env -S pip install -r
0 commit comments