Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sphinx_js/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
auto_class_directive_bound_to_app,
auto_function_directive_bound_to_app,
auto_module_directive_bound_to_app,
auto_summary_directive_bound_to_app,
sphinx_js_type_role,
)
from .jsdoc import Analyzer as JsAnalyzer
Expand Down Expand Up @@ -145,6 +146,7 @@ def setup(app: Sphinx) -> None:
fix_js_make_xref()
fix_staticfunction_objtype()
add_type_param_field_to_directives()
app.setup_extension("sphinx.ext.autosummary")

# I believe this is the best place to run jsdoc. I was tempted to use
# app.add_source_parser(), but I think the kind of source it's referring to
Expand All @@ -163,6 +165,9 @@ def setup(app: Sphinx) -> None:
app.add_directive_to_domain(
"js", "automodule", auto_module_directive_bound_to_app(app)
)
app.add_directive_to_domain(
"js", "autosummary", auto_summary_directive_bound_to_app(app)
)

# TODO: We could add a js:module with app.add_directive_to_domain().

Expand Down
15 changes: 13 additions & 2 deletions sphinx_js/directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
AutoClassRenderer,
AutoFunctionRenderer,
AutoModuleRenderer,
JsRenderer,
AutoSummaryRenderer,
Renderer,
)


Expand Down Expand Up @@ -75,7 +76,7 @@ class JsDirective(Directive):

option_spec = {"short-name": flag}

def _run(self, renderer_class: type[JsRenderer], app: Sphinx) -> list[Node]:
def _run(self, renderer_class: type[Renderer], app: Sphinx) -> list[Node]:
renderer = renderer_class.from_directive(self, app)
note_dependencies(app, renderer.dependencies())
return renderer.rst_nodes()
Expand Down Expand Up @@ -187,3 +188,13 @@ def run(self) -> list[Node]:
return self._run(AutoModuleRenderer, app)

return AutoModuleDirective


def auto_summary_directive_bound_to_app(app: Sphinx) -> type[Directive]:
class JsDocSummary(JsDirective):
required_arguments = 1

def run(self) -> list[Node]:
return self._run(AutoSummaryRenderer, app)

return JsDocSummary
1 change: 1 addition & 0 deletions sphinx_js/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class Return:
@define
class Module:
filename: str
deppath: str | None
path: Pathname
line: int
attributes: list["TopLevel"] = Factory(list)
Expand Down
Loading