Skip to content

Commit

Permalink
Update portray to forked version and add support for readthedocs
Browse files Browse the repository at this point in the history
  • Loading branch information
sveinugu committed Oct 31, 2023
1 parent f54401d commit 3f59900
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 57 deletions.
11 changes: 5 additions & 6 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@ build:
os: "ubuntu-22.04"
tools:
python: "3.10"
jobs:
post_create_environment:
commands:
# Install poetry
# https://python-poetry.org/docs/#installing-manually
- pip install poetry==1.4.0

# Tell poetry to not use a virtual environment
- poetry config virtualenvs.create false
post_install:

# Install dependencies with 'docs' dependency group
# https://python-poetry.org/docs/managing-dependencies/#dependency-groups
- poetry install --with docs


mkdocs:
configuration: pyproject.toml
# Generate documentation
- python scripts/generate_portray_docs for_readthedocs
32 changes: 32 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
site_name: Omnipy
theme:
name: material
custom_dir: docs/overrides
# features:
# - content.code.annotation
# - navigation.tabs
# - search.highlight
# - toc.integrate
language: en
palette:
- scheme: omnipy
extra_css:
- stylesheets/extra.css
markdown_extensions:
- admonition
- codehilite
- extra
- pymdownx.details
- pymdownx.highlight:
anchor_linenums: true
line_spans: __span
pygments_lang_class: true
- pymdownx.inlinehilite
- pymdownx.snippets
- pymdownx.superfences

#markdown_extensions:
# - admonition
# - attr_list
# - footnotes
# - md_in_html
28 changes: 1 addition & 27 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ furo = "^2022.12.7"
sphinx = "^6.1.3"
sphinx-autoapi = "^2.0.1"
sphinx-copybutton = "^0.5.1"
portray = "^1.8.0"
portray = {git = "https://github.com/HeinrichAD/portray.git"}
docstring-parser = "^0.15"
pymdown-extensions = "^10.0.1"

Expand Down Expand Up @@ -137,31 +137,5 @@ testpaths = [
docs_dir = "docs/portray"
directory = "."

[[tool.portray.extra_markdown_extensions]]
[tool.portray.extra_markdown_extensions."pymdownx.highlight"]
anchor_linenums = true
line_spans = "__span"
pygments_lang_class = true

[tool.portray.mkdocs]
extra_css = ["stylesheets/extra.css"]
markdown_extensions = [
"admonition",
"codehilite",
"extra",
"pymdownx.details",
"pymdownx.inlinehilite",
"pymdownx.snippets",
"pymdownx.superfences",
]

[tool.portray.mkdocs.theme]
#favicon = "art/logo_small.png"
#logo = "art/logo_small.png"
name = "material"
custom_dir = "docs/overrides"
palette = {scheme = "omnipy"}


[tool.portray.pdocs]
template_dir = "docs/templates/pdocs"
49 changes: 49 additions & 0 deletions scripts/generate_portray_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env python
from enum import Enum
import os

import pdocs.doc
from portray import api as portray_api
import typer


def _is_exported(ident_name):
return not ident_name.startswith("_") or ident_name in [
'__enter__',
'__exit__',
'__cmp__',
'__eq__',
'__getattr__',
'__setattr__',
'__getitem_',
'__setitem__',
'__delitem__',
'__iter__',
'__call__'
]


pdocs.doc._is_exported = _is_exported


class Command(str, Enum):
IN_BROWSER = 'in_browser'
AS_HTML = 'as_html'
FOR_READTHEDOCS = 'for_readthedocs'
# ON_GITHUB_PAGES = 'on_github_pages'


def main(cmd: Command):
if cmd == Command.IN_BROWSER:
portray_api.in_browser()
if cmd == Command.AS_HTML:
portray_api.as_html()
if cmd == Command.FOR_READTHEDOCS:
readthedocs_path = os.getenv('READTHEDOCS_OUTPUT')
portray_api.as_html(output_dir=os.path.join(readthedocs_path, 'html'))
# elif cmd == Command.ON_GITHUB_PAGES:
# portray_api.on_github_pages()


if __name__ == '__main__':
typer.run(main)
24 changes: 0 additions & 24 deletions scripts/generate_portray_docs_in_browser.py

This file was deleted.

0 comments on commit 3f59900

Please sign in to comment.