|
5 | 5 | import importlib |
6 | 6 | import inspect |
7 | 7 | import os |
| 8 | +from sphinx.application import Sphinx |
| 9 | +from sphinx.writers.html5 import HTML5Translator |
| 10 | +import posixpath |
8 | 11 | # -- Project information ----------------------------------------------------- |
9 | 12 | # |
10 | 13 | sys.path.insert(0, pathlib.Path(__file__).parents[0].resolve().as_posix()) |
|
13 | 16 |
|
14 | 17 | project = 'OntoAligner' |
15 | 18 | copyright = f'{str(datetime.datetime.now().year)} SciKnowOrg' |
16 | | -author = 'Hamed Babaei Giglou' |
17 | 19 | release = '0.2.0' |
18 | 20 |
|
19 | 21 |
|
|
23 | 25 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom |
24 | 26 | # ones. |
25 | 27 | extensions = [ |
| 28 | + "sphinx_toolbox.collapse", |
26 | 29 | "sphinx.ext.autodoc", |
27 | 30 | "sphinx.ext.napoleon", |
28 | 31 | "myst_parser", |
|
32 | 35 | "sphinx.ext.linkcode", |
33 | 36 | "sphinx_inline_tabs", |
34 | 37 | "sphinxcontrib.mermaid", |
35 | | - # "sphinx.ext.mathjax" |
36 | | - |
37 | | - # 'sphinx.ext.duration', |
38 | | - # 'sphinx.ext.doctest', |
39 | 38 | 'sphinx.ext.autodoc', |
40 | 39 | 'sphinx.ext.autosummary', |
41 | | - # 'sphinx.ext.intersphinx', |
42 | 40 | ] |
43 | 41 |
|
44 | 42 | # autosummary_generate = True # Turn on sphinx.ext.autosummary |
|
73 | 71 | ("Github", "https://github.com/sciknoworg/OntoAligner"), |
74 | 72 | ("Pypi", "https://pypi.org/project/OntoAligner/") |
75 | 73 | ], |
| 74 | + "navigation_depth": 4, |
| 75 | + "collapse_navigation": True, |
| 76 | + "logo_only": True, |
76 | 77 | } |
77 | 78 |
|
78 | 79 | html_static_path = ["_static"] |
@@ -131,3 +132,27 @@ def linkcode_resolve(domain, info): |
131 | 132 | relative_path = os.path.relpath(file_path, start=os.path.dirname(__file__)) |
132 | 133 | end_line = start_line + len(source_lines) - 1 |
133 | 134 | return f"{repo_url}/blob/{branch}/{relative_path}#L{start_line}-L{end_line}" |
| 135 | + |
| 136 | +def visit_download_reference(self, node): |
| 137 | + root = "https://github.com/sciknoworg/OntoAligner/tree/main" |
| 138 | + atts = {"class": "reference download", "download": ""} |
| 139 | + |
| 140 | + if not self.builder.download_support: |
| 141 | + self.context.append("") |
| 142 | + elif "refuri" in node: |
| 143 | + atts["class"] += " external" |
| 144 | + atts["href"] = node["refuri"] |
| 145 | + self.body.append(self.starttag(node, "a", "", **atts)) |
| 146 | + self.context.append("</a>") |
| 147 | + elif "reftarget" in node and "refdoc" in node: |
| 148 | + atts["class"] += " external" |
| 149 | + atts["href"] = posixpath.join(root, os.path.dirname(node["refdoc"]), node["reftarget"]) |
| 150 | + self.body.append(self.starttag(node, "a", "", **atts)) |
| 151 | + self.context.append("</a>") |
| 152 | + else: |
| 153 | + self.context.append("") |
| 154 | + |
| 155 | +HTML5Translator.visit_download_reference = visit_download_reference |
| 156 | + |
| 157 | +def setup(app: Sphinx): |
| 158 | + pass |
0 commit comments