Skip to content

Commit ce45134

Browse files
Merge pull request #6 from fern-api/overhaul
feat: removed all sphinx and kept it to Fern
2 parents 0846f33 + b9bd6fc commit ce45134

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+480
-21921
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# See https://pre-commit.com for more information
22
# See https://pre-commit.com/hooks.html for more hooks
33

4-
exclude: ^tests/.*\.md|tests/.*\.rst|tests/.*\.xml|docs/apidocs/.*
4+
exclude: ^tests/.*\.md
55

66
repos:
77
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -23,5 +23,5 @@ repos:
2323
hooks:
2424
- id: mypy
2525
args: [--config-file=pyproject.toml]
26-
additional_dependencies: ["sphinx~=7.3", "typer[all]"]
26+
additional_dependencies: ["typer[all]"]
2727
exclude: ^tests/.*\.py$

.readthedocs.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

README.md

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,37 @@
1-
# sphinx-autodoc2-fern
1+
# py2fern
22

3-
Generate Fern-compatible API documentation from Python packages using static analysis.
3+
Generate [Fern](https://buildwithfern.com) API documentation from Python packages using static analysis.
44

5-
Fork of [`sphinx-autodoc2`](https://github.com/sphinx-extensions2/sphinx-autodoc2) with [Fern](https://buildwithfern.com) output support.
5+
Simplified fork of [`sphinx-autodoc2`](https://github.com/sphinx-extensions2/sphinx-autodoc2) focused purely on **Python → Fern markdown** output.
66

77
## Installation
88

99
```bash
10-
pip install sphinx-autodoc2-fern
10+
pipx install py2fern
1111
```
1212

1313
## Usage
1414

15-
Generate Fern-compatible markdown documentation:
15+
Generate Fern markdown documentation:
1616

1717
```bash
18-
autodoc2 --renderer fern /path/to/your/package
18+
py2fern write /path/to/your/package
19+
```
20+
21+
Specify output directory:
22+
23+
```bash
24+
py2fern write /path/to/your/package --output ./docs/api
1925
```
2026

2127
This creates:
22-
- Markdown files with Fern-compatible frontmatter and slugs
23-
- `navigation.yml` for Fern docs structure
24-
- Tables with proper linking and descriptions
28+
- **MDX files** with Fern-compatible frontmatter and slugs
29+
- **`navigation.yml`** for Fern docs structure
2530

2631
## Acknowledgments
2732

2833
This project is a fork of the excellent [`sphinx-autodoc2`](https://github.com/sphinx-extensions2/sphinx-autodoc2) by Chris Sewell. All credit for the core functionality goes to the original project.
2934

30-
## Design and comparison to sphinx-autoapi
31-
32-
The original sphinx-autodoc2 was created with the following goals:
33-
34-
- Static analysis of Python code, so things like `if TYPE_CHECKING` were handled correctly
35-
- Support for MyST docstrings (see <https://github.com/executablebooks/MyST-Parser/issues/228>)
36-
- Also support for transitioning from `rst` to `md`, i.e. mixing docstrings
37-
- Make it simple and minimise the amount of configuration and rebuilds necessary
38-
- Support for building public API via `__all__` variable
39-
40-
I am not looking to support other languages tha Python (at least for now).
41-
42-
[sphinx-autoapi](https://github.com/readthedocs/sphinx-autoapi) was a good candidate, but it had a few issues:
43-
44-
- It does not support MyST docstrings: <https://github.com/readthedocs/sphinx-autoapi/issues/287>
45-
- It does not support the `__all__` very well: <https://github.com/readthedocs/sphinx-autoapi/issues/358>
46-
- The analysis and rendering are coupled, making it difficult to test, modify and use outside of Sphinx
47-
48-
I've use a lot of their code, for the `astroid` static analysis, but I've made a number of "improvements":
49-
50-
- separating concerns: analysis and template writing
51-
- type annotations for code base
52-
- fixed `a | b` annotations inference
53-
- added analysis of `functools.singledispatch` and their registers
54-
- handling of `__all__`
55-
- docstrings (and summaries) are now parsed with the correct source/line, i.e. warnings point to the correct location in the source file
56-
- added `:canonical:` to `py` directives
57-
- Moved away from using jinja templates, to using python functions
58-
- IMO the templates were too complex and hard to read,
59-
plus they do not benefit from any form of type checking, linting, etc.
60-
- uses `list-table`, instead of `auto-summary` directive
61-
6235
## Development
6336

6437
All configuration is mainly in `pyproject.toml`.

0 commit comments

Comments
 (0)