Skip to content

Commit f7d9dad

Browse files
authored
📝 refactor docs generation
* 📝 switch to a Markdown extension that displays better on GitHub * 📝 deduplicate source of README.md/index.md * 📝 simplify and unnest nav generation #40
1 parent 29cc8b1 commit f7d9dad

File tree

6 files changed

+32
-438
lines changed

6 files changed

+32
-438
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@ Alternatively, you can install it with [pip]:
407407
pip install hatch hatch-pip-compile
408408
```
409409

410+
<!--skip-->
411+
410412
---
411413

412414
---
@@ -417,6 +419,8 @@ pip install hatch hatch-pip-compile
417419

418420
#### See the [Changelog]
419421

422+
<!--skip-->
423+
420424
[pip-compile]: https://github.com/jazzband/pip-tools
421425
[pip-sync]: https://github.com/jazzband/pip-tools
422426
[hatch]: https://github.com/pypa/hatch

docs/contributing.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22

33
## Environment Setup
44

5-
!!! tip "pipx"
6-
7-
This documentaion uses [pipx] to
8-
install and manage non-project command line tools like `hatch` and
9-
`pre-commit`. If you don't already have `pipx` installed, make sure to
10-
see their [documentation](https://pypa.github.io/pipx/installation/).
11-
If you prefer not to use `pipx`, you can use `pip` instead.
5+
> TIP: **pipx**
6+
>
7+
> This documentaion uses [pipx] to
8+
> install and manage non-project command line tools like `hatch` and
9+
> `pre-commit`. If you don't already have `pipx` installed, make sure to
10+
> see their [documentation](https://pypa.github.io/pipx/installation/).
11+
> If you prefer not to use `pipx`, you can use `pip` instead.
1212
1313
1. Install [hatch](https://github.com/pypa/hatch)
1414

1515
```shell
1616
pipx install hatch
1717
```
1818

19-
!!! note "pre-commit"
20-
21-
Hatch will attempt to set up pre-commit hooks for you using
22-
[pre-commit]. If you don't already,
23-
make sure to install pre-commit as well: `pipx install pre-commit`
19+
> NOTE: **pre-commit**
20+
>
21+
> Hatch will attempt to set up pre-commit hooks for you using
22+
> [pre-commit]. If you don't already,
23+
> make sure to install pre-commit as well: `pipx install pre-commit`
2424
2525
2. Build the Virtual Environment
2626

docs/gen_ref_pages.py renamed to docs/gen_pages.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
project_dir = Path(__file__).resolve().parent.parent
1313
source_code = project_dir.joinpath("hatch_pip_compile")
14-
nav = mkdocs_gen_files.Nav()
1514

1615
for path in sorted(source_code.rglob("*.py")):
1716
module_path = path.relative_to(project_dir).with_suffix("")
@@ -26,13 +25,15 @@
2625
elif parts[-1] == "__main__":
2726
continue
2827

29-
nav[parts] = doc_path.as_posix()
30-
3128
with mkdocs_gen_files.open(full_doc_path, "w") as fd:
32-
ident = ".".join(parts)
33-
fd.write(f"::: {ident}")
29+
fd.write(f"# `{parts[-1]}`\n\n::: {'.'.join(parts)}")
3430

3531
mkdocs_gen_files.set_edit_path(full_doc_path, path)
3632

37-
with mkdocs_gen_files.open("reference/SUMMARY.md", "w") as nav_file:
38-
nav_file.writelines(nav.build_literate_nav())
33+
34+
with open("README.md") as in_file:
35+
readme_content = in_file.read()
36+
# Exclude parts that are between two exact `<!--skip-->` lines
37+
readme_content = "\n".join(readme_content.split("\n<!--skip-->\n")[::2])
38+
with mkdocs_gen_files.open("index.md", "w") as index_file:
39+
index_file.write(readme_content)

0 commit comments

Comments
 (0)