Skip to content

feat: converting documentation to mkdocs #5276

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ tests/test_orca/images/linux/failed/

doc/python/raw.githubusercontent.com/

docs/

# Don't ignore dataset files
!*.csv.gz
!*.geojson.gz
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ then explains the technical aspects of preparing your contribution.

## Code of Conduct

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

## Different Ways to Contribute

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

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

Expand Down
40 changes: 40 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
site_name: "Plotly.py Docs"
docs_dir: pages
site_dir: docs

plugins:
- search
- gen-files:
scripts:
- scripts/gen_ref_pages.py
- literate-nav:
nav_file: SUMMARY.md
- mkdocstrings:
handlers:
python:
options:
docstring_style: google
show_source: false
show_root_heading: true
show_root_toc_entry: true
merge_init_into_class: true

nav:
- Home: index.md
- API Reference: reference/
- Project:
- license.md
- conduct.md
- contributing.md

theme:
name: "material"

markdown_extensions:
- def_list
- markdown_include.include:
base_path: docs
- footnotes

exclude_docs: >
*~
1 change: 1 addition & 0 deletions pages/conduct.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{!../CODE_OF_CONDUCT.md!}
1 change: 1 addition & 0 deletions pages/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{!../CONTRIBUTING.md!}
1 change: 1 addition & 0 deletions pages/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{!../README.md!}
1 change: 1 addition & 0 deletions pages/license.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{!../LICENSE.txt!}
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ dev_core = [
dev_build = [
"plotly[dev_core]",
"build",
"jupyter"
"jupyter",
"markdown-include",
"mkdocs",
"mkdocs-material",
"mkdocstrings[python]",
"mkdocs-gen-files",
"mkdocs-literate-nav"
]
dev_optional = [
"plotly[dev_build]",
Expand Down
32 changes: 32 additions & 0 deletions scripts/gen_ref_pages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Generate the code reference pages and navigation."""

from pathlib import Path
import mkdocs_gen_files

nav = mkdocs_gen_files.Nav()

for path in sorted(Path("plotly").rglob("*.py")):
module_path = path.relative_to(".").with_suffix("")
doc_path = path.relative_to(".").with_suffix(".md")
full_doc_path = Path("reference", doc_path)

parts = tuple(module_path.parts)

if parts[-1] == "__init__":
parts = parts[:-1]
doc_path = doc_path.with_name("index.md")
full_doc_path = full_doc_path.with_name("index.md")
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}\n\n")
fd.write(f"::: {ident}")

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())
654 changes: 653 additions & 1 deletion uv.lock

Large diffs are not rendered by default.