Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 refactor docs generation #40

Merged
merged 3 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ Alternatively, you can install it with [pip]:
pip install hatch hatch-pip-compile
```

<!--skip-->

---

---
Expand All @@ -417,6 +419,8 @@ pip install hatch hatch-pip-compile

#### See the [Changelog]

<!--skip-->

[pip-compile]: https://github.com/jazzband/pip-tools
[pip-sync]: https://github.com/jazzband/pip-tools
[hatch]: https://github.com/pypa/hatch
Expand Down
24 changes: 12 additions & 12 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

## Environment Setup

!!! tip "pipx"

This documentaion uses [pipx] to
install and manage non-project command line tools like `hatch` and
`pre-commit`. If you don't already have `pipx` installed, make sure to
see their [documentation](https://pypa.github.io/pipx/installation/).
If you prefer not to use `pipx`, you can use `pip` instead.
> TIP: **pipx**
>
> This documentaion uses [pipx] to
> install and manage non-project command line tools like `hatch` and
> `pre-commit`. If you don't already have `pipx` installed, make sure to
> see their [documentation](https://pypa.github.io/pipx/installation/).
> If you prefer not to use `pipx`, you can use `pip` instead.

1. Install [hatch](https://github.com/pypa/hatch)

```shell
pipx install hatch
```

!!! note "pre-commit"

Hatch will attempt to set up pre-commit hooks for you using
[pre-commit]. If you don't already,
make sure to install pre-commit as well: `pipx install pre-commit`
> NOTE: **pre-commit**
>
> Hatch will attempt to set up pre-commit hooks for you using
> [pre-commit]. If you don't already,
> make sure to install pre-commit as well: `pipx install pre-commit`

2. Build the Virtual Environment

Expand Down
15 changes: 8 additions & 7 deletions docs/gen_ref_pages.py → docs/gen_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

project_dir = Path(__file__).resolve().parent.parent
source_code = project_dir.joinpath("hatch_pip_compile")
nav = mkdocs_gen_files.Nav()

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

nav[parts] = doc_path.as_posix()

with mkdocs_gen_files.open(full_doc_path, "w") as fd:
ident = ".".join(parts)
fd.write(f"::: {ident}")
fd.write(f"# `{parts[-1]}`\n\n::: {'.'.join(parts)}")

mkdocs_gen_files.set_edit_path(full_doc_path, path)

with mkdocs_gen_files.open("reference/SUMMARY.md", "w") as nav_file:
nav_file.writelines(nav.build_literate_nav())

with open("README.md") as in_file:
readme_content = in_file.read()
# Exclude parts that are between two exact `<!--skip-->` lines
readme_content = "\n".join(readme_content.split("\n<!--skip-->\n")[::2])
with mkdocs_gen_files.open("index.md", "w") as index_file:
index_file.write(readme_content)
Loading