Skip to content

Commit

Permalink
updated config files to new compas2 theme
Browse files Browse the repository at this point in the history
  • Loading branch information
chenkasirer committed Sep 4, 2024
1 parent 521a7e5 commit 3578218
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 137 deletions.
238 changes: 107 additions & 131 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,122 +1,80 @@
# flake8: noqa
# -*- coding: utf-8 -*-

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = "1.0"

import sys
import os
import inspect
import importlib

import sphinx_compas_theme
from sphinx.ext.napoleon.docstring import NumpyDocstring

sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../src'))
import sphinx_compas2_theme
from sphinx.writers import html
from sphinx.writers import html5

# -- General configuration ------------------------------------------------

project = "compas_cadwork"
copyright = ""
author = ""
release = "0.4.4"
version = ".".join(release.split(".")[0:2])
project = "COMPAS cadwork"
copyright = "Gramazio Kohler Research"
author = "Gramazio Kohler Research, ETH Zurich"
organization = "gramaziokohler"
package = "compas_cadwork"

master_doc = "index"
source_suffix = [".rst", ]
templates_path = sphinx_compas_theme.get_autosummary_templates_path()
exclude_patterns = []

pygments_style = "sphinx"
show_authors = True
source_suffix = {".rst": "restructuredtext", ".md": "markdown"}
templates_path = sphinx_compas2_theme.get_autosummary_templates_path()
exclude_patterns = sphinx_compas2_theme.default_exclude_patterns
add_module_names = True
language = None
language = "en"

latest_version = sphinx_compas2_theme.get_latest_version()

if latest_version == "Unreleased":
release = "Unreleased"
version = "latest"
else:
release = latest_version
version = ".".join(release.split(".")[0:2]) # type: ignore

# -- Extension configuration ------------------------------------------------

extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.doctest",
"sphinx.ext.coverage",
"sphinx.ext.linkcode",
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"sphinx.ext.githubpages",
"matplotlib.sphinxext.plot_directive",
]
extensions = sphinx_compas2_theme.default_extensions

# autodoc options
# numpydoc options

autodoc_mock_imports = [
"System",
"clr",
"Eto",
"Rhino",
"Grasshopper",
"scriptcontext",
"rhinoscriptsyntax",
"bpy",
"bmesh",
"mathutils"
]
numpydoc_show_class_members = False
numpydoc_class_members_toctree = False
numpydoc_attributes_as_param_list = True
numpydoc_show_inherited_class_members = False

# bibtex options

# autodoc options

autodoc_type_aliases = {}
autodoc_typehints_description_target = "documented"
autodoc_mock_imports = sphinx_compas2_theme.default_mock_imports
autodoc_default_options = {
"undoc-members": True,
"show-inheritance": True,
}

autodoc_member_order = "alphabetical"
autodoc_member_order = "groupwise"
autodoc_typehints = "description"
autodoc_class_signature = "separated"

autoclass_content = "class"

def skip(app, what, name, obj, would_skip, options):
if name.startswith('_'):
return True
return would_skip

def setup(app):
app.connect("autodoc-skip-member", skip)
app.connect("autodoc-skip-member", sphinx_compas2_theme.skip)


# autosummary options

autosummary_generate = True
autosummary_mock_imports = sphinx_compas2_theme.default_mock_imports

# napoleon options

napoleon_google_docstring = False
napoleon_numpy_docstring = True
napoleon_include_init_with_doc = False
napoleon_include_private_with_doc = False
napoleon_include_special_with_doc = True
napoleon_use_admonition_for_examples = False
napoleon_use_admonition_for_notes = False
napoleon_use_admonition_for_references = False
napoleon_use_ivar = False
napoleon_use_param = False
napoleon_use_rtype = False
# graph options

# plot options

plot_include_source = False
plot_html_show_source_link = False
plot_html_show_formats = False

# docstring sections

def parse_attributes_section(self, section):
return self._format_fields("Attributes", self._consume_fields())

NumpyDocstring._parse_attributes_section = parse_attributes_section

def patched_parse(self):
self._sections["attributes"] = self._parse_attributes_section
self._unpatched_parse()

NumpyDocstring._unpatched_parse = NumpyDocstring._parse
NumpyDocstring._parse = patched_parse
plot_formats = ["png"]

# intersphinx options

Expand All @@ -127,64 +85,82 @@ def patched_parse(self):

# linkcode

def linkcode_resolve(domain, info):
if domain != 'py':
return None
if not info['module']:
return None
if not info['fullname']:
return None

package = info['module'].split('.')[0]
if not package.startswith('compas_cadwork'):
return None

module = importlib.import_module(info['module'])
parts = info['fullname'].split('.')

if len(parts) == 1:
obj = getattr(module, info['fullname'])
filename = inspect.getmodule(obj).__name__.replace('.', '/')
lineno = inspect.getsourcelines(obj)[1]
elif len(parts) == 2:
obj_name, attr_name = parts
obj = getattr(module, obj_name)
attr = getattr(obj, attr_name)
if inspect.isfunction(attr):
filename = inspect.getmodule(obj).__name__.replace('.', '/')
lineno = inspect.getsourcelines(attr)[1]
else:
return None
else:
return None

return f"https://github.com/gramaziokohler/compas_cadwork/blob/master/src/{filename}.py#L{lineno}"
linkcode_resolve = sphinx_compas2_theme.get_linkcode_resolve(organization, package)

# extlinks

extlinks = {}
extlinks = {
"rhino": ("https://developer.rhino3d.com/api/RhinoCommon/html/T_%s.htm", "%s"),
"blender": ("https://docs.blender.org/api/2.93/%s.html", "%s"),
}

# from pytorch

sphinx_compas2_theme.replace(html.HTMLTranslator)
sphinx_compas2_theme.replace(html5.HTML5Translator)

# -- Options for HTML output ----------------------------------------------

html_theme = "compaspkg"
html_theme_path = sphinx_compas_theme.get_html_theme_path()
html_theme = "sidebaronly"
html_title = project

favicons = [
{
"rel": "icon",
"href": "compas.ico",
}
]

html_theme_options = {
"package_name" : "compas_cadwork",
"package_title" : project,
"package_version" : release,
"package_author" : "",
"package_docs" : "https://gramaziokohler.github.io/compas_cadwork/",
"package_repo" : "https://github.com/gramaziokohler/compas_cadwork",
"package_old_versions_txt": "https://gramaziokohler.github.io/compas_cadwork/doc_versions.txt"
"external_links": [
{"name": "COMPAS Framework", "url": "https://compas.dev"},
],
"icon_links": [
{
"name": "GitHub",
"url": f"https://github.com/{organization}/{package}",
"icon": "fa-brands fa-github",
"type": "fontawesome",
},
{
"name": "Discourse",
"url": "http://forum.compas-framework.org/",
"icon": "fa-brands fa-discourse",
"type": "fontawesome",
},
{
"name": "PyPI",
"url": f"https://pypi.org/project/{package}/",
"icon": "fa-brands fa-python",
"type": "fontawesome",
},
],
"switcher": {
"json_url": f"https://raw.githubusercontent.com/{organization}/{package}/gh-pages/versions.json",
"version_match": version,
},
"logo": {
"image_light": "_static/compas_icon_white.png",
"image_dark": "_static/compas_icon_white.png",
"text": "COMPAS cadwork",
},
"navigation_depth": 2,
}

html_context = {
"github_url": "https://github.com",
"github_user": organization,
"github_repo": package,
"github_version": "main",
"doc_path": "docs",
}

html_context = {}
html_static_path = sphinx_compas_theme.get_html_static_path()
html_static_path = sphinx_compas2_theme.get_html_static_path() + ["_static"]
html_css_files = []
html_extra_path = []
html_last_updated_fmt = ""
html_copy_source = False
html_show_sourcelink = False
html_show_sourcelink = True
html_permalinks = False
html_add_permalinks = None
html_permalinks_icon = ""
html_compact_lists = True
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ autopep8
black
bump2version >=1.0.1
check-manifest >=0.36
compas_invocations
compas_invocations2
doc8
flake8
graphviz
Expand All @@ -17,7 +17,7 @@ nbsphinx
pydocstyle
pytest >=3.2
sphinx >=3.4
sphinx_compas_theme >=0.15.18
sphinx_compas2_theme
twine
wheel
-e .
8 changes: 4 additions & 4 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import os

from compas_invocations import build
from compas_invocations import docs
from compas_invocations import style
from compas_invocations import tests
from compas_invocations2 import build
from compas_invocations2 import docs
from compas_invocations2 import style
from compas_invocations2 import tests
from invoke import Collection

ns = Collection(
Expand Down

0 comments on commit 3578218

Please sign in to comment.