Skip to content

Commit 49c6a89

Browse files
NeoZhangJianyuarthwpre-commit-ci[bot]
authored
[online doc] add script to fix miss readme issue (#2330)
* add script to fix miss readme * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: ZhangJianyu <zhang.jianyu@outlook.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 722d41b commit 49c6a89

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

docs/build_docs/add_readme.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import os
2+
import sys
3+
4+
5+
def main(inputs):
6+
# output_file = f"{input_file}.new"
7+
for input_file in inputs:
8+
output_file = input_file
9+
res = []
10+
with open(input_file, "r") as f:
11+
for line in f.readlines():
12+
start = 0
13+
while True:
14+
pos = line.find('href="./', start)
15+
16+
if pos >= 0:
17+
# print("find", line)
18+
end_pos = line.find('">', pos)
19+
line = line[:end_pos] + '/README.md">' + line[end_pos + 2 :]
20+
start = end_pos + 2
21+
else:
22+
break
23+
24+
res.append(line)
25+
26+
with open(output_file, "w") as f:
27+
f.write("".join(res))
28+
29+
print(f"save to {output_file}")
30+
31+
32+
if __name__ == "__main__":
33+
main(sys.argv[1:])

docs/build_docs/build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ source env_sphinx/bin/activate
8383
cp -rf ../docs/ ./source
8484
cp -f "../README.md" "./source/docs/source/Welcome.md"
8585
cp -f "../SECURITY.md" "./source/docs/source/SECURITY.md"
86-
86+
cp -rf ../examples ./source/docs/source/
87+
#python add_readme.py ./source/docs/source/examples/3.x_api/README.md
8788

8889
all_md_files=`find ./source/docs -name "*.md"`
8990
for md_file in ${all_md_files}

0 commit comments

Comments
 (0)