Skip to content

Commit f028442

Browse files
committed
Changing documentation to mkdocs and plugins to automatically document and create features
1 parent 4d7ae63 commit f028442

File tree

7 files changed

+188
-158
lines changed

7 files changed

+188
-158
lines changed

{{cookiecutter.project_slug}}/.flake8

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
[flake8]
2-
#ignore = E203, E266, E501, W503, T499, ANN101, ANN102, ANN002, ANN003, S101, SCS108
3-
ignore = E501,SCS109
2+
ignore = E203, E266, E501, W503, T499
43
max-line-length = 79
54
enable-extensions=G
6-
#select = B,C,E,F,W,T4,T0,N8,DC,DAR,SCS
5+
#select = B,C,E,F,W,T4,T0,N8,DC,DAR
76
import-order-style = google
87
docstring-convention = google
9-
per-file-ignores = tests/*:S101, SCS108
8+
per-file-ignores = tests/*:S101
109
max-complexity = 10
1110
exclude =
1211
docs/
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import mkdocs_gen_files
2+
from pathlib import Path
3+
4+
docs_parent_dir = Path(__file__).parent.parent
5+
6+
7+
readme_path = docs_parent_dir / "README.md"
8+
if readme_path.exists():
9+
with open(readme_path, "r") as r:
10+
with mkdocs_gen_files.open("readme.md", "w") as f:
11+
f.write(r.read())
12+
13+
14+
head_lines = (
15+
"Feature:",
16+
"Scenario:",
17+
"Scenario Outline:",
18+
"Rule:",
19+
"Example:",
20+
"Background:",
21+
)
22+
ignore_lines = ("@", "#")
23+
features_dir = docs_parent_dir / "features"
24+
for feature_path in features_dir.glob("**/*.feature"):
25+
with open(feature_path, "r") as f:
26+
relative_dir = feature_path.parent.relative_to(features_dir)
27+
with mkdocs_gen_files.open(
28+
f"scenarios/{relative_dir}/{feature_path.stem}.md", "w"
29+
) as gf:
30+
f_line_list = f.readlines()
31+
for line in f_line_list:
32+
if any([line.strip().startswith(l) for l in head_lines]):
33+
write_line = f"### {line}\n"
34+
elif any([line.strip().startswith(l) for l in ignore_lines]):
35+
continue
36+
else:
37+
write_line = f"> {line}"
38+
39+
gf.write(write_line)
40+

{{cookiecutter.project_slug}}/docs/mkdocs.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@ site_dir: html
77
plugins:
88
- search
99
- mkapi
10+
- awesome-pages
11+
- gen-files:
12+
scripts:
13+
- gen_pages.py
1014

1115
theme:
12-
name: readthedocs
16+
name: material
1317

1418
nav:
1519
- index.md
20+
- ... | readme.md
21+
- ... | scenarios/**/*.md
1622
- API: mkapi/api/{{cookiecutter.package_name}}
1723
- Tests: mkapi/tests/tests
1824

0 commit comments

Comments
 (0)