diff --git a/pyproject.toml b/pyproject.toml index faf1b76..aea4815 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,6 @@ dependencies = [ "packaging", "sphinx", "sphinx-astropy", - "sphinx_bootstrap_theme", "sphinx-rtd-theme", "toml", diff --git a/sphinx_asdf/__init__.py b/sphinx_asdf/__init__.py index ce7553d..98bd379 100644 --- a/sphinx_asdf/__init__.py +++ b/sphinx_asdf/__init__.py @@ -4,8 +4,6 @@ from .connections import ( add_labels_to_nodes, autogenerate_schema_docs, - handle_page_context, - on_build_finished, update_app_config, ) from .directives import AsdfAutoschemas, AsdfSchema @@ -27,9 +25,7 @@ def setup(app): app.connect("builder-inited", autogenerate_schema_docs) app.connect("config-inited", update_app_config) - app.connect("html-page-context", handle_page_context) app.connect("doctree-read", add_labels_to_nodes) - app.connect("build-finished", on_build_finished) static_dir = os.path.join(os.path.dirname(__file__), "static") diff --git a/sphinx_asdf/connections.py b/sphinx_asdf/connections.py index 36d8bf8..2a4e484 100644 --- a/sphinx_asdf/connections.py +++ b/sphinx_asdf/connections.py @@ -8,12 +8,8 @@ from docutils import nodes from sphinx.util import rst from sphinx.util.docutils import sphinx_domains -from sphinx.util.fileutil import copy_asset from .directives import schema_def -from .nodes import schema_doc - -TEMPLATE_PATH = os.path.join(os.path.dirname(__file__), "templates") # docutils 0.19.0 fixed a bug in traverse/findall # https://sourceforge.net/p/docutils/bugs/448/ @@ -119,13 +115,6 @@ def update_app_config(app, config): config.html_context["sphinx_asdf_version"] = dist.version -def handle_page_context(app, pagename, templatename, ctx, doctree): - # Use custom template when rendering pages containing schema documentation. - # This allows us to selectively include bootstrap - if doctree is not None and traverse(doctree, schema_doc): - return os.path.join(TEMPLATE_PATH, "schema.html") - - def normalize_name(name): for char in [".", "_", "/"]: name = name.replace(char, "-") @@ -154,11 +143,3 @@ def add_labels_to_nodes(app, document): anonlabels[name] = docname, labelid # labelname -> docname, labelid, sectionname labels[name] = docname, labelid, "" - - -def on_build_finished(app, exc): - if exc is None: - for asset in ["sphinx_asdf.css", "sphinx_asdf.js"]: - src = posixpath.join(posixpath.dirname(__file__), "static", asset) - dst = posixpath.join(app.outdir, "_static") - copy_asset(src, dst) diff --git a/sphinx_asdf/directives.py b/sphinx_asdf/directives.py index 2e8e8d0..de33d16 100644 --- a/sphinx_asdf/directives.py +++ b/sphinx_asdf/directives.py @@ -146,7 +146,7 @@ def run(self): return [docnodes] def _create_toc(self, schema): - toc = nodes.compound() + toc = nodes.bullet_list() toc.append(toc_link(text=SCHEMA_DEF_SECTION_TITLE)) if "examples" in schema: toc.append(toc_link(text=EXAMPLE_SECTION_TITLE)) @@ -226,7 +226,7 @@ def _create_ref_node(self, ref): def _create_enum_node(self, enum_values): enum_nodes = nodes.compound() - enum_nodes.append(nodes.line(text="Only the following values are valid for this node:")) + enum_nodes.append(nodes.paragraph(text="Only the following values are valid for this node:")) markdown = "\n".join([f"* **{val}**" for val in enum_values]) enum_nodes.extend(self._markdown_to_nodes(markdown, "")) return enum_nodes @@ -240,14 +240,14 @@ def _create_array_items_node(self, items, path): node_list = nodes.compound() if isinstance(items, list): text = "The first {} item{} in the list must be the following types:" - node_list.append(nodes.line(text=text.format(len(items), "s" if len(items) > 1 else ""))) + node_list.append(nodes.paragraph(text=text.format(len(items), "s" if len(items) > 1 else ""))) item_list = nodes.bullet_list() for i, it in enumerate(items): item_path = self._append_to_path(path, i) item_list.append(self._process_properties(it, top=True, path=item_path)) node_list.append(item_list) else: - node_list.append(nodes.line(text="Items in the array are restricted to the following types:")) + node_list.append(nodes.paragraph(text="Items in the array are restricted to the following types:")) node_list.append(self._process_properties(items, top=True, path=path)) return node_list @@ -260,21 +260,21 @@ def _process_validation_keywords(self, schema, typename=None, path=""): node_list.append(nodes.emphasis(text="No length restriction")) if schema.get("minLength", 0): text = f"Minimum length: {schema['minLength']}" - node_list.append(nodes.line(text=text)) + node_list.append(nodes.paragraph(text=text)) if "maxLength" in schema: text = f"Maximum length: {schema['maxLength']}" - node_list.append(nodes.line(text=text)) + node_list.append(nodes.paragraph(text=text)) if "pattern" in schema: - node_list.append(nodes.line(text="Must match the following pattern:")) + node_list.append(nodes.paragraph(text="Must match the following pattern:")) node_list.append(nodes.literal_block(text=schema["pattern"], language="none")) elif typename == "array": if schema.get("minItems", 0): text = f"Minimum length: {schema['minItems']}" - node_list.append(nodes.line(text=text)) + node_list.append(nodes.paragraph(text=text)) if "maxItems" in schema: text = f"Maximum length: {schema['maxItems']}" - node_list.append(nodes.line(text=text)) + node_list.append(nodes.paragraph(text=text)) if "additionalItems" in schema and "items" in schema: if isinstance(schema["items"], list) and schema["additionalItems"] is False: node_list.append(nodes.emphasis(text="Additional items not permitted")) @@ -288,10 +288,10 @@ def _process_validation_keywords(self, schema, typename=None, path=""): elif typename in ["integer", "number"]: if "minimum" in schema: text = f"Minimum value: {schema['minimum']}" - node_list.append(nodes.line(text=text)) + node_list.append(nodes.paragraph(text=text)) if "maximum" in schema: text = f"Maximum value: {schema['maximum']}" - node_list.append(nodes.line(text=text)) + node_list.append(nodes.paragraph(text=text)) if "enum" in schema: node_list.append(self._create_enum_node(schema["enum"])) @@ -303,10 +303,10 @@ def _process_validation_keywords(self, schema, typename=None, path=""): else: default = schema["default"] text = f"Default value: {default}" - node_list.append(nodes.line(text=text)) + node_list.append(nodes.paragraph(text=text)) else: default_node = nodes.compound() - default_node.append(nodes.line(text="Default value:")) + default_node.append(nodes.paragraph(text="Default value:")) default_node.append(nodes.literal_block(text=pformat(schema["default"]), language="none")) node_list.append(default_node) @@ -338,7 +338,7 @@ def _process_properties(self, schema, top=False, path=""): for key, node in schema["properties"].items(): new_path = self._append_to_path(path, key) treenodes.append(self._create_property_node(key, node, key in required, path=new_path)) - comment = nodes.line(text="This type is an object with the following properties:") + comment = nodes.paragraph(text="This type is an object with the following properties:") return schema_properties(None, *[comment, treenodes], id=path) elif "type" in schema: details = self._process_top_type(schema, path=path) diff --git a/sphinx_asdf/nodes.py b/sphinx_asdf/nodes.py index 5c3ea47..6bd0fbf 100644 --- a/sphinx_asdf/nodes.py +++ b/sphinx_asdf/nodes.py @@ -17,19 +17,18 @@ def depart_html(self, node): class schema_title(nodes.compound): def visit_html(self, node): - self.body.append(r'