Skip to content

Commit

Permalink
build: disable doc generation
Browse files Browse the repository at this point in the history
  • Loading branch information
makkus committed Nov 7, 2023
1 parent c3b30df commit c6a74e0
Show file tree
Hide file tree
Showing 13 changed files with 217 additions and 188 deletions.
66 changes: 33 additions & 33 deletions .github/workflows/build-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,39 +122,39 @@ jobs:
- name: Run Ruff
run: ruff --format=github src/

build-docs:
name: build documentation
runs-on: ubuntu-latest
needs:
- test-linux
- mypy-linux
- linting-linux
steps:
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: pip cache
id: pip-cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.*') }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: install kiara
run: pip install -U .[dev_documentation,doc]
- run: git config --global user.email "markus@frkl.io"
- run: git config --global user.name "Markus Binsteiner"
- name: create latest documentation
if: ${{ ( github.ref == 'refs/heads/develop') }}
run: FAIL_DOC_BUILD_ON_ERROR=true mike deploy --push latest && mike set-default --push latest
- name: extract tag name
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: create stable documentation
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: FAIL_DOC_BUILD_ON_ERROR=true mike deploy --push --update-alias --title "v ${RELEASE_VERSION}" "${RELEASE_VERSION}" stable
# build-docs:
# name: build documentation
# runs-on: ubuntu-latest
# needs:
# - test-linux
# - mypy-linux
# - linting-linux
# steps:
# - name: Set up Python 3.10
# uses: actions/setup-python@v4
# with:
# python-version: "3.10"
# - name: pip cache
# id: pip-cache
# uses: actions/cache@v3
# with:
# path: ~/.cache/pip
# key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.*') }}
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - name: install kiara
# run: pip install -U .[dev_documentation,doc]
# - run: git config --global user.email "markus@frkl.io"
# - run: git config --global user.name "Markus Binsteiner"
# - name: create latest documentation
# if: ${{ ( github.ref == 'refs/heads/develop') }}
# run: FAIL_DOC_BUILD_ON_ERROR=true mike deploy --push latest && mike set-default --push latest
# - name: extract tag name
# run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
# - name: create stable documentation
# if: ${{ startsWith(github.ref, 'refs/tags/') }}
# run: FAIL_DOC_BUILD_ON_ERROR=true mike deploy --push --update-alias --title "v ${RELEASE_VERSION}" "${RELEASE_VERSION}" stable

publish_python_package:
name: publish python package
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ dev_documentation = [
"mkdocs-material>=8.0.0",
"mkdocs-section-index>0.3.0",
"mkdocstrings[python]>=0.18",
"mkdocs-gen-files>=0.3.1;python_version>='3.7'"
"mkdocs-gen-files>=0.3.1"
]

dev_testing = [
Expand Down
154 changes: 77 additions & 77 deletions src/kiara/doc/mkdocstrings/collector.py
Original file line number Diff line number Diff line change
@@ -1,78 +1,78 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2022-2022, Markus Binsteiner
#
# Mozilla Public License, version 2.0 (see LICENSE or https://www.mozilla.org/en-US/MPL/2.0/)

from __future__ import annotations

import builtins

from mkdocstrings.handlers.base import BaseCollector, CollectionError, CollectorItem
from mkdocstrings.loggers import get_logger

from kiara.context import Kiara, KiaraContextInfo
from kiara.interfaces.python_api.models.info import ItemInfo
from kiara.utils import log_exception

logger = get_logger(__name__)


class KiaraCollector(BaseCollector):

"""
The class responsible for loading Jinja templates and rendering them.
It defines some configuration options, implements the `render` method,
and overrides the `update_env` method of the [`BaseRenderer` class][mkdocstrings.handlers.base.BaseRenderer].
"""

default_config: dict = {"docstring_style": "google", "docstring_options": {}}
"""The default selection options.
Option | Type | Description | Default
------ | ---- | ----------- | -------
**`docstring_style`** | `"google" | "numpy" | "sphinx" | None` | The docstring style to use. | `"google"`
**`docstring_options`** | `dict[str, Any]` | The options for the docstring parser. | `{}`
"""

fallback_config: dict = {"fallback": True}

def __init__(self) -> None:
"""Initialize the collector."""
self._kiara: Kiara = Kiara.instance()

def collect(self, identifier: str, config: dict) -> CollectorItem:
"""
Collect the documentation tree given an identifier and selection options.
Arguments:
---------
identifier: The dotted-path of a Python object available in the Python path.
config: Selection options, used to alter the data collection done by `pytkdocs`.
Raises:
------
CollectionError: When there was a problem collecting the object documentation.
Returns:
-------
The collected object-tree.
"""
tokens = identifier.split(".")

if tokens[0] != "kiara_info":
return None

item_type = tokens[1]
item_id = ".".join(tokens[2:])
if not item_id:
raise CollectionError(f"Invalid id: {identifier}")

ctx: KiaraContextInfo = builtins.plugin_package_context_info # type: ignore
try:
item: ItemInfo = ctx.get_info(item_type=item_type, item_id=item_id)
except Exception as e:
log_exception(e)
raise CollectionError(f"Invalid id: {identifier}")

return {"obj": item, "identifier": identifier}
# # Copyright (c) 2022-2022, Markus Binsteiner
# #
# # Mozilla Public License, version 2.0 (see LICENSE or https://www.mozilla.org/en-US/MPL/2.0/)
#
# from __future__ import annotations
#
# import builtins
#
# from mkdocstrings.handlers.base import CollectionError, CollectorItem, BaseHandler
# from mkdocstrings.loggers import get_logger
#
# from kiara.context import Kiara, KiaraContextInfo
# from kiara.interfaces.python_api.models.info import ItemInfo
# from kiara.utils import log_exception
#
# logger = get_logger(__name__)
#
#
# class KiaraCollector(BaseHandler):
#
# """
# The class responsible for loading Jinja templates and rendering them.
# It defines some configuration options, implements the `render` method,
# and overrides the `update_env` method of the [`BaseRenderer` class][mkdocstrings.handlers.base.BaseRenderer].
# """
#
# default_config: dict = {"docstring_style": "google", "docstring_options": {}}
# """The default selection options.
# Option | Type | Description | Default
# ------ | ---- | ----------- | -------
# **`docstring_style`** | `"google" | "numpy" | "sphinx" | None` | The docstring style to use. | `"google"`
# **`docstring_options`** | `dict[str, Any]` | The options for the docstring parser. | `{}`
# """
#
# fallback_config: dict = {"fallback": True}
#
# def __init__(self) -> None:
# """Initialize the collector."""
# self._kiara: Kiara = Kiara.instance()
#
# def collect(self, identifier: str, config: dict) -> CollectorItem:
# """
# Collect the documentation tree given an identifier and selection options.
#
# Arguments:
# ---------
# identifier: The dotted-path of a Python object available in the Python path.
# config: Selection options, used to alter the data collection done by `pytkdocs`.
#
#
# Raises:
# ------
# CollectionError: When there was a problem collecting the object documentation.
#
#
# Returns:
# -------
# The collected object-tree.
# """
# tokens = identifier.split(".")
#
# if tokens[0] != "kiara_info":
# return None
#
# item_type = tokens[1]
# item_id = ".".join(tokens[2:])
# if not item_id:
# raise CollectionError(f"Invalid id: {identifier}")
#
# ctx: KiaraContextInfo = builtins.plugin_package_context_info # type: ignore
# try:
# item: ItemInfo = ctx.get_info(item_type=item_type, item_id=item_id)
# except Exception as e:
# log_exception(e)
# raise CollectionError(f"Invalid id: {identifier}")
#
# return {"obj": item, "identifier": identifier}
103 changes: 66 additions & 37 deletions src/kiara/doc/mkdocstrings/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@

import typing

from mkdocstrings.handlers.base import BaseHandler
from mkdocstrings.handlers.base import BaseHandler, CollectionError, CollectorItem

__all__ = ["get_handler"]

from kiara.context import KiaraContextInfo

# from kiara.defaults import KIARA_RESOURCES_FOLDER
from kiara.doc.mkdocstrings.collector import KiaraCollector
from kiara.doc.mkdocstrings.renderer import KiaraInfoRenderer
# from kiara.doc.mkdocstrings.collector import KiaraCollector
# from kiara.doc.mkdocstrings.renderer import KiaraInfoRenderer
from kiara.interfaces.python_api.models.info import ItemInfo
from kiara.utils import log_exception


class KiaraHandler(BaseHandler):
Expand All @@ -31,42 +34,68 @@ class KiaraHandler(BaseHandler):
domain: str = "kiara"
enable_inventory: bool = True

# load_inventory = staticmethod(inventory.list_object_urls)
#
# @classmethod
# def load_inventory(
# cls,
# in_file: typing.BinaryIO,
# url: str,
# base_url: typing.Optional[str] = None,
# **kwargs: typing.Any,
# ) -> typing.Iterator[typing.Tuple[str, str]]:
# """Yield items and their URLs from an inventory file streamed from `in_file`.
# This implements mkdocstrings' `load_inventory` "protocol" (see plugin.py).
# Arguments:
# in_file: The binary file-like object to read the inventory from.
# url: The URL that this file is being streamed from (used to guess `base_url`).
# base_url: The URL that this inventory's sub-paths are relative to.
# **kwargs: Ignore additional arguments passed from the config.
# Yields:
# Tuples of (item identifier, item URL).
# """
#
# print("XXXXXXXXXXXXXXXXXXXXXXXXXXXX")
#
# if base_url is None:
# base_url = posixpath.dirname(url)
#
# for item in Inventory.parse_sphinx(
# in_file, domain_filter=("py",)
# ).values():
# yield item.name, posixpath.join(base_url, item.uri)
def collect(
self, identifier: str, config: typing.MutableMapping[str, typing.Any]
) -> CollectorItem:
"""
Collect the documentation tree given an identifier and selection options.
Arguments:
---------
identifier: The dotted-path of a Python object available in the Python path.
config: Selection options, used to alter the data collection done by `pytkdocs`.
Raises:
------
CollectionError: When there was a problem collecting the object documentation.
Returns:
-------
The collected object-tree.
"""
tokens = identifier.split(".")

if tokens[0] != "kiara_info":
return None

item_type = tokens[1]
item_id = ".".join(tokens[2:])
if not item_id:
raise CollectionError(f"Invalid id: {identifier}")

ctx: KiaraContextInfo = builtins.plugin_package_context_info # type: ignore # noqa
try:
item: ItemInfo = ctx.get_info(item_type=item_type, item_id=item_id)
except Exception as e:
log_exception(e)
raise CollectionError(f"Invalid id: {identifier}")

return {"obj": item, "identifier": identifier}

def get_anchors(self, data: CollectorItem) -> typing.Tuple[str, ...]:

if data is None:
return ()

return (data["identifier"], data["kiara_id"], data["obj"].get_id())

def render(
self, data: CollectorItem, config: typing.Mapping[str, typing.Any]
) -> str:

# final_config = ChainMap(config, self.default_config)

obj = data["obj"]
html: str = obj.create_html()
return html


def get_handler(
theme: str,
custom_templates: typing.Union[str, None] = None,
**config: typing.Any,
config_file_path: typing.Union[None, str] = None,
) -> KiaraHandler:
"""
Simply return an instance of `PythonHandler`.
Expand All @@ -90,7 +119,7 @@ def get_handler(
# )

return KiaraHandler(
collector=KiaraCollector(),
# renderer=KiaraInfoRenderer("kiara", theme, custom_templates),
renderer=KiaraInfoRenderer("kiara", theme),
"kiara",
theme=theme,
custom_templates=custom_templates,
)
Loading

0 comments on commit c6a74e0

Please sign in to comment.