Files
flame/doc/_sphinx/conf.py
Munsterlander 35d5533ded docs!: Adds doc-kill melos command and bumps requirements (#2397)
As mentioned in #2395, there are several lingering issues that can be solved by bumping the Python package requirements up. All packages need / can run on Python 3.8+, so the docs do not need to be updated regarding that.

This PR specifically fixes the following warnings:

flame\doc\bridge_packages\bridge_packages.md:4: WARNING: 'myst' reference target not found: ..\bridge_packages\flame_audio\flame_audio.md
....There were a lot of those....

`attrs_image` is deprecated.  Use `attrs_inline` instead.

Additionally, this PR adds a new command melos doc-kill which executes the kill-server.py script. This script relies on psutil which has been added to the requirements.txt, but allows a cross platform ability to isolate and kill process threads that are locking the port 8000. This commonly happens when you exit melos doc-serve and the internal web server doesn't die as well. This may not be an issue for Unix platforms, but for Windows users its extremely annoying.

The only alternative for Windows users is to manually do:

netstat -ano | findstr :8000
// Then run:
taskkill /PID XXXXX /F 

As I mentioned in the other PR, I split this out so it can be debated mainly for the bump in requirements; however, I feel the benefits are very worth it. I marked this as breaking just because it changes the base package requirements and adds a package which may not qualify as breaking, depending on how you look at it.

Edit: Forgot that this PR also fixes a typo in the melos doc-serve description and corrects the misspelling of everytime to every time.
2023-03-13 09:15:07 +00:00

153 lines
4.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Configuration file for the Sphinx documentation builder.
#
# 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 docutils.nodes
import html
import os
import sys
sys.path.insert(0, os.path.abspath('.'))
root_dir = os.path.abspath(
os.path.join(os.path.dirname(__file__), '..', '..')
)
# -- Project information -----------------------------------------------------
project = 'Flame'
copyright = '2021, Blue Fire Team'
author = 'Blue Fire Team'
root_doc = "index"
# -- General configuration ---------------------------------------------------
primary_domain = 'dart'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'myst_parser', # Markdown support
'sphinxcontrib.mermaid',
'extensions.dart_domain',
'extensions.flutter_app',
'extensions.package',
'extensions.yarn_lexer',
]
# Configuration options for MyST:
# https://myst-parser.readthedocs.io/en/latest/syntax/optional.html
myst_enable_extensions = [
'attrs_inline',
'colon_fence',
'deflist',
'dollarmath',
'html_admonition',
'html_image',
'replacements',
'smartquotes',
'strikethrough',
'substitution',
'tasklist',
]
# Auto-generate link anchors for headers at levels H1 and H2
myst_heading_anchors = 4
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-the-linkcheck-builder
linkcheck_ignore = [
r'https://examples.flame-engine.org/#/.*',
r'https://pub.dev/documentation/flame/--VERSION--/',
]
# -- Options for dartdoc extension -------------------------------------------
dartdoc_roots = {
'flame': os.path.join(root_dir, 'packages/flame/lib'),
'jenny': os.path.join(root_dir, 'packages/flame_jenny/jenny/lib'),
}
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages.
html_theme = "flames"
html_theme_options = {}
html_title = "Flame"
html_logo = "images/logo_flame.png"
html_favicon = "images/favicon.ico"
# Style for syntax highlighting
pygments_style = 'monokai'
# 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', 'scripts', 'theme']
html_js_files = ['versions.js', 'menu-expand.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 <h1/>")
del titles[0] # remove the <h1> title
html_text = "<div id='toc-local' class='list-group'>\n"
html_text += " <div class='header'><i class='fa fa-list'></i> Contents</div>\n"
for title, node_id, level in titles:
if level <= 1:
return document.reporter.error("More than one <h1> title on the page")
html_text += f" <a href='#{node_id}' class='list-group-item level-{level-1}'>" \
f"{html.escape(title)}</a>\n"
html_text += "</div>\n"
return html_text
# Emitted when the HTML builder has created a context dictionary to render
# a template with this can be used to add custom elements to the context.
def on_html_page_context(app, pagename, templatename, context, doctree):
context["get_local_toc"] = lambda: get_local_toc(doctree)
def setup(app):
this_dir = os.path.dirname(__file__)
theme_dir = os.path.abspath(os.path.join(this_dir, 'theme'))
app.add_css_file('flames.css')
app.add_html_theme('flames', theme_dir)
app.connect("html-page-context", on_html_page_context)