Skip to content

Commit da5218f

Browse files
committed
misc doc improvements
1 parent 1a581eb commit da5218f

14 files changed

+94
-32
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from docutils import nodes
2+
from sphinx import addnodes
3+
from sphinx.application import Sphinx
4+
from sphinx.transforms.post_transforms import SphinxPostTransform
5+
from sphinx.util import logging
6+
7+
8+
logger = logging.getLogger(__name__)
9+
10+
11+
def is_public_internal_ref_target(target: str) -> bool:
12+
return target.startswith("idom.") and not target.rsplit(".", 1)[-1].startswith("_")
13+
14+
15+
class OnlyWarnOnBrokenInternalRefs(SphinxPostTransform):
16+
"""
17+
Warns about broken cross-reference links, but only for idom.
18+
This is very similar to the sphinx option ``nitpicky=True`` (see
19+
:py:class:`sphinx.transforms.post_transforms.ReferencesResolver`), but there
20+
is no way to restrict that option to a specific package.
21+
"""
22+
23+
# this transform needs to happen before ReferencesResolver
24+
default_priority = 5
25+
26+
def run(self) -> None:
27+
for node in self.document.traverse(addnodes.pending_xref):
28+
target = node["reftarget"]
29+
30+
if is_public_internal_ref_target(target):
31+
# let the domain try to resolve the reference
32+
found_ref = self.env.domains[node["refdomain"]].resolve_xref(
33+
self.env,
34+
node.get("refdoc", self.env.docname),
35+
self.app.builder,
36+
node["reftype"],
37+
target,
38+
node,
39+
nodes.TextElement("", ""),
40+
)
41+
42+
# warn if resolve_xref did not return or raised
43+
if not found_ref:
44+
logger.warning(
45+
f"API link {target} is broken.", location=node, type="ref"
46+
)
47+
48+
49+
def setup(app: Sphinx) -> None:
50+
app.add_post_transform(OnlyWarnOnBrokenInternalRefs)

docs/source/architectural-patterns.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ As a result, IDOM was developed to help solve these problems.
5757
Ecosystem Independence
5858
----------------------
5959

60-
IDOM has a flexible set of :ref:`core abstractions <Core Concepts>` that allow it to
61-
interface with its peers. At the time of writing Jupyter, Dash, and Bokeh (via Panel)
62-
are supported, while Streamlit is in the works:
60+
IDOM has a flexible set of :ref:`Core Abstractions` that allow it to interface with its
61+
peers. At the time of writing Jupyter, Dash, and Bokeh (via Panel) are supported, while
62+
Streamlit is in the works:
6363

6464
- idom-jupyter_ (try it now with Binder_)
6565
- idom-dash_

docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"patched_html_translator",
6666
"widget_example",
6767
"build_custom_js",
68+
"only_warn_on_broken_internal_refs",
6869
]
6970

7071
# Add any paths that contain templates here, relative to this directory.

docs/source/core-concepts.rst renamed to docs/source/core-abstractions.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
Core Concepts
2-
=============
3-
4-
This section covers core features of IDOM that are used in making interactive
5-
interfaces.
1+
Core Abstractions
2+
=================
63

74

85
Pure Components

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ IDOM
1515
:hidden:
1616
:caption: Advanced Topics
1717

18-
core-concepts
18+
core-abstractions
1919
javascript-components
2020
architectural-patterns
2121
specifications

docs/source/life-cycle-hooks.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,9 @@ use_ref
284284
285285
ref_container = use_ref(initial_value)
286286
287-
Returns a mutable :class:`~idom.core.hooks.Ref` object that has a single
288-
:attr:`~idom.core.hooks.Ref.current` attribute that at first contains the
289-
``initial_state``. The identity of the ``Ref`` object will be preserved for the lifetime
290-
of the component.
287+
Returns a mutable :class:`~idom.utils.Ref` object that has a single
288+
:attr:`~idom.utils.Ref.current` attribute that at first contains the ``initial_state``.
289+
The identity of the ``Ref`` object will be preserved for the lifetime of the component.
291290

292291
A ``Ref`` is most useful if you need to incur side effects since updating its
293292
``.current`` attribute doesn't trigger a re-render of the component. You'll often use this

docs/source/roadmap.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Roadmap
3434
they need purpose-built
3535
`compiler plugins <https://github.com/idom-team/idom-react-component-cookiecutter/blob/1cc31b8690f84cb90dd861f2f47873b1d5711f74/%7B%7Bcookiecutter.repository_name%7D%7D/js/rollup.config.js>`__
3636
that will convert imports of React to point to the location ``react.js`` will be
37-
once the component has been loaded via :class:`~idom.client.module.Module`.
37+
once the component has been loaded via ``idom.client.module.Module``
3838

3939
Ideally developers of custom components should be able to operate in isolation
4040
without assuming anything about the environment they are running in. This has the

noxfile.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,18 @@ def test_docs(session: Session) -> None:
161161
"""Verify that the docs build and that doctests pass"""
162162
install_requirements_file(session, "build-docs")
163163
install_idom_dev(session, extras="all")
164-
session.run("sphinx-build", "-T", "-b", "html", "docs/source", "docs/build")
165-
session.run("sphinx-build", "-T", "-b", "doctest", "docs/source", "docs/build")
164+
session.run(
165+
"sphinx-build",
166+
"-a", # re-write all output files
167+
"-T", # show full tracebacks
168+
"-W", # turn warnings into errors
169+
"--keep-going", # complete the build, but still report warnings as errors
170+
"-b",
171+
"html",
172+
"docs/source",
173+
"docs/build",
174+
)
175+
session.run("sphinx-build", "-b", "doctest", "docs/source", "docs/build")
166176

167177

168178
@nox.session

src/idom/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
"""The location IDOM will use to store its client application
3939
4040
This directory **MUST** be treated as a black box. Downstream applications **MUST NOT**
41-
assume anything about the structure of this directory see :mod:`idom.client.manage` for
42-
a set of publically available APIs for working with the client.
41+
assume anything about the structure of this directory see :mod:`idom.web.module` for a
42+
set of publically available APIs for working with the client.
4343
"""
4444

4545
IDOM_FEATURE_INDEX_AS_DEFAULT_KEY = _Option(

src/idom/core/dispatcher.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ async def dispatch_single_view(
3636
send: SendCoroutine,
3737
recv: RecvCoroutine,
3838
) -> None:
39+
"""Run a dispatch loop for a single view instance"""
3940
with layout:
4041
async with create_task_group() as task_group:
4142
task_group.start_soon(_single_outgoing_loop, layout, send)
@@ -50,6 +51,7 @@ async def dispatch_single_view(
5051
async def create_shared_view_dispatcher(
5152
layout: Layout, run_forever: bool = False
5253
) -> AsyncIterator[_SharedViewDispatcherFuture]:
54+
"""Enter a dispatch context where all subsequent view instances share the same state"""
5355
with layout:
5456
(
5557
dispatch_shared_view,
@@ -94,6 +96,7 @@ def dispatch_shared_view_soon(
9496
def ensure_shared_view_dispatcher_future(
9597
layout: Layout,
9698
) -> Tuple[Future[None], SharedViewDispatcher]:
99+
"""Ensure the future of a dispatcher created by :func:`create_shared_view_dispatcher`"""
97100
dispatcher_future: Future[SharedViewDispatcher] = Future()
98101

99102
async def dispatch_shared_view_forever() -> None:

0 commit comments

Comments
 (0)