Skip to content

Commit 5eec0b0

Browse files
committed
feat: converting documentation to mkdocs
1 parent 6d864c4 commit 5eec0b0

File tree

10 files changed

+740
-4
lines changed

10 files changed

+740
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ tests/test_orca/images/linux/failed/
1313

1414
doc/python/raw.githubusercontent.com/
1515

16+
docs/
17+
1618
# Don't ignore dataset files
1719
!*.csv.gz
1820
!*.geojson.gz

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ then explains the technical aspects of preparing your contribution.
88

99
## Code of Conduct
1010

11-
Please note that all contributos are required to abide by our [Code of Conduct](CODE_OF_CONDUCT.md).
11+
Please note that all contributos are required to abide by our Code of Conduct.
1212

1313
## Different Ways to Contribute
1414

@@ -38,7 +38,7 @@ it is important to understand the structure of the code and the repository.
3838
These are organized in subdirectories according to what they test:
3939
see the "Setup" section below for more details.
4040

41-
- Documentation is found in `doc/`, and its structure is described in [its README file](doc/README.md).
41+
- Documentation is found in `doc/`, and its structure is described in its README file.
4242
The documentation is a great place to start contributing,
4343
since you can add or modify examples without setting up a full environment.
4444

mkdocs.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
site_name: "Plotly.py Docs"
2+
docs_dir: pages
3+
site_dir: docs
4+
5+
plugins:
6+
- search
7+
- gen-files:
8+
scripts:
9+
- scripts/gen_ref_pages.py
10+
- literate-nav:
11+
nav_file: SUMMARY.md
12+
- mkdocstrings:
13+
handlers:
14+
python:
15+
options:
16+
docstring_style: google
17+
show_source: false
18+
show_root_heading: true
19+
show_root_toc_entry: true
20+
merge_init_into_class: true
21+
22+
nav:
23+
- Home: index.md
24+
- API Reference: reference/
25+
- Project:
26+
- license.md
27+
- conduct.md
28+
- contributing.md
29+
30+
theme:
31+
name: "material"
32+
33+
markdown_extensions:
34+
- def_list
35+
- markdown_include.include:
36+
base_path: docs
37+
- footnotes
38+
39+
exclude_docs: >
40+
*~

pages/conduct.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{!../CODE_OF_CONDUCT.md!}

pages/contributing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{!../CONTRIBUTING.md!}

pages/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{!../README.md!}

pages/license.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{!../LICENSE.txt!}

pyproject.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ dev_core = [
5050
dev_build = [
5151
"plotly[dev_core]",
5252
"build",
53-
"jupyter"
53+
"jupyter",
54+
"markdown-include",
55+
"mkdocs",
56+
"mkdocs-material",
57+
"mkdocstrings[python]",
58+
"mkdocs-gen-files",
59+
"mkdocs-literate-nav"
5460
]
5561
dev_optional = [
5662
"plotly[dev_build]",

scripts/gen_ref_pages.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""Generate the code reference pages and navigation."""
2+
3+
from pathlib import Path
4+
import mkdocs_gen_files
5+
6+
nav = mkdocs_gen_files.Nav()
7+
8+
for path in sorted(Path("plotly").rglob("*.py")):
9+
module_path = path.relative_to(".").with_suffix("")
10+
doc_path = path.relative_to(".").with_suffix(".md")
11+
full_doc_path = Path("reference", doc_path)
12+
13+
parts = tuple(module_path.parts)
14+
15+
if parts[-1] == "__init__":
16+
parts = parts[:-1]
17+
doc_path = doc_path.with_name("index.md")
18+
full_doc_path = full_doc_path.with_name("index.md")
19+
elif parts[-1] == "__main__":
20+
continue
21+
22+
nav[parts] = doc_path.as_posix()
23+
24+
with mkdocs_gen_files.open(full_doc_path, "w") as fd:
25+
ident = ".".join(parts)
26+
fd.write(f"# {ident}\n\n")
27+
fd.write(f"::: {ident}")
28+
29+
mkdocs_gen_files.set_edit_path(full_doc_path, path)
30+
31+
with mkdocs_gen_files.open("reference/SUMMARY.md", "w") as nav_file:
32+
nav_file.writelines(nav.build_literate_nav())

uv.lock

Lines changed: 653 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)