diff --git a/doc/_sphinx/conf.py b/doc/_sphinx/conf.py index e88953e3f8e..f2d1b2d8d16 100644 --- a/doc/_sphinx/conf.py +++ b/doc/_sphinx/conf.py @@ -3,14 +3,14 @@ # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html - +import docutils +import os # -- Project information ----------------------------------------------------- project = 'Flame' copyright = '2021, Blue Fire Team' author = 'Blue Fire Team' - root_doc = "index" @@ -47,17 +47,8 @@ # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. -html_theme = "sphinx_book_theme" - -# See https://sphinx-book-theme.readthedocs.io/en/latest/customize/index.html -html_theme_options = { - "logo_only": True, - "path_to_docs": "doc", - "repository_branch": "main", - "repository_url": "https://github.com/flame-engine/flame", - "use_edit_page_button": True, - "use_repository_button": True, -} +html_theme = "flames" +html_theme_options = {} html_title = "Flame" html_logo = "images/logo_flame.png" html_favicon = "images/favicon.ico" @@ -68,6 +59,66 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['images', 'styles', 'scripts'] -html_css_files = ['custom.css'] +html_static_path = ['images', 'scripts', 'theme'] html_js_files = ['versions.js'] + +# -- Custom setup ------------------------------------------------------------ +class TitleCollector(docutils.nodes.SparseNodeVisitor): + def __init__(self, document): + self.level = 0 + self.titles = [] + super().__init__(document) + + def visit_section(self, node): + title_class = docutils.nodes.title + self.level += 1 + if node.children and isinstance(node.children[0], title_class): + title = node.children[0].astext() + node_id = node.get("ids")[0] + self.titles.append([title, node_id, self.level]) + + def depart_section(self, node): + self.level -= 1 + + + +def get_local_toc(document): + if not document: + return "" + visitor = TitleCollector(document) + document.walkabout(visitor) + titles = visitor.titles + if not titles: + return "" + + levels = sorted(set(item[2] for item in titles)) + if levels.index(titles[0][2]) != 0: + return document.reporter.error( + "First title on the page is not
") + del titles[0] # remove the