-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #215 from josephlewis42/jl/feat/mkdocs
Added mkdocs
- Loading branch information
Showing
8 changed files
with
213 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: zimscraperlib Documentation | ||
--- | ||
|
||
{% | ||
include-markdown "../README.md" | ||
%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: License | ||
--- | ||
|
||
``` | ||
--8<-- "LICENSE" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
Script called by mkdocs-gen-files that generates markdown documents | ||
with API reference placeholders. | ||
https://oprypin.github.io/mkdocs-gen-files/api.html | ||
""" | ||
|
||
from pathlib import Path | ||
|
||
import mkdocs_gen_files | ||
|
||
nav = mkdocs_gen_files.Nav() | ||
|
||
root = Path(__file__).parent.parent.parent | ||
src = root / "src" | ||
api_reference = Path("api_reference") | ||
|
||
for path in sorted(src.rglob("*.py")): | ||
module_path = path.relative_to(src).with_suffix("") | ||
|
||
# Package docs get the parent module name. | ||
if module_path.name == "__init__": | ||
module_path = module_path.parent | ||
elif module_path.name.startswith("_"): | ||
# Skip other hidden items | ||
continue | ||
identifier = ".".join(module_path.parts) | ||
|
||
doc_path = identifier + ".md" | ||
full_doc_path = api_reference / doc_path | ||
|
||
nav[identifier] = doc_path | ||
|
||
# Create a document with mkdocstrings placeholders. | ||
with mkdocs_gen_files.open(full_doc_path, "w") as fd: | ||
fd.write(f"---\ntitle: {identifier}\n---\n\n::: {identifier}") | ||
|
||
# Make the edit button on the page link to the source file. | ||
mkdocs_gen_files.set_edit_path(full_doc_path, Path("..") / path.relative_to(root)) | ||
|
||
# Write a navigation file that will be interpreted by literate-nav. | ||
with mkdocs_gen_files.open(api_reference / "NAVIGATION.md", "w") as fd: | ||
fd.writelines(nav.build_literate_nav()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
site_name: Python Scraperlib | ||
site_description: 'Collection of Python code to re-use across Python-based OpenZIM scrapers.' | ||
repo_url: https://github.com/openzim/python-scraperlib | ||
repo_name: GitHub | ||
edit_uri: edit/main/docs/ | ||
|
||
validation: | ||
omitted_files: warn | ||
absolute_links: warn | ||
unrecognized_links: warn | ||
|
||
nav: | ||
- Home: index.md | ||
- Design: | ||
- Functional Architecture: functional_architecture.md | ||
- Software Architecture: software_architecture.md | ||
- Technical Architecture: technical_architecture.md | ||
- API Reference: api_reference/ | ||
- License: license.md | ||
|
||
theme: | ||
name: material | ||
logo: assets/openzim.png | ||
palette: | ||
# Light mode | ||
- scheme: default | ||
toggle: | ||
icon: material/brightness-7 | ||
name: Switch to dark mode | ||
# Dark mode | ||
- scheme: slate | ||
toggle: | ||
icon: material/brightness-4 | ||
name: Switch to light mode | ||
features: | ||
# Use XHR for page changes to avoid page flash during navigation. | ||
- navigation.instant | ||
- navigation.instant.progress | ||
# Use tabs and section headers rather than a single side navbar. | ||
- navigation.tabs | ||
- navigation.sections | ||
# Add buttons to edit content | ||
- content.action.edit | ||
|
||
markdown_extensions: | ||
- pymdownx.snippets: | ||
base_path: . | ||
check_paths: true | ||
|
||
plugins: | ||
- search | ||
|
||
# Replace externally hosted assets for compliance with various privacy regulations. | ||
- privacy | ||
|
||
# Nicely include markdown, e.g. to rewrite relative links | ||
- include-markdown | ||
|
||
# Generate API docs and navigation for them | ||
- gen-files: | ||
scripts: | ||
- docs/scripts/generate_api_nav.py | ||
|
||
# Import additional nav from NAVIGATION.md files, like the one produced | ||
# by gen-files. | ||
- literate-nav: | ||
nav_file: NAVIGATION.md | ||
|
||
# Generate items | ||
- mkdocstrings: | ||
handlers: | ||
python: | ||
# Set up cross-references to Python types | ||
import: | ||
- https://docs.python.org/3/objects.inv | ||
paths: [src] | ||
options: | ||
docstring_section_style: list | ||
filters: ['!^_'] | ||
heading_level: 2 | ||
inherited_members: true | ||
merge_init_into_class: true | ||
separate_signature: true | ||
show_signature_annotations: true | ||
show_symbol_type_heading: true | ||
show_symbol_type_toc: true | ||
signature_crossrefs: true | ||
summary: true | ||
# Typically this should be off, but zimscraperlib has many | ||
# items that won't be picked up because they lack docs | ||
# or are using single line comments (like constants). | ||
show_if_no_docstring: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters