Skip to content

Commit fcb65df

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

9 files changed

+81
-24
lines changed
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

+3-3
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

+1
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

+2-5
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

+1-1
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

noxfile.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,17 @@ 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+
"-T", # show full tracebacks
167+
"-W", # turn warnings into errors
168+
"--keep-going", # complete the build, but still report warnings as errors
169+
"-b",
170+
"html",
171+
"docs/source",
172+
"docs/build",
173+
)
174+
session.run("sphinx-build", "-b", "doctest", "docs/source", "docs/build")
166175

167176

168177
@nox.session

src/idom/config.py

+2-2
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/server/prefab.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ def multiview_server(
8080
) -> Tuple[MultiViewMount, Server[_App]]:
8181
"""Set up a server where views can be dynamically added.
8282
83-
In other words this allows the user to work with IDOM in an imperative manner.
84-
Under the hood this uses the :func:`idom.widgets.common.multiview` function to
85-
add the views on the fly.
83+
In other words this allows the user to work with IDOM in an imperative manner. Under
84+
the hood this uses the :func:`idom.widgets.multiview` function to add the views on
85+
the fly.
8686
8787
Parameters:
8888
server: The server type to start up as a daemon
@@ -93,8 +93,8 @@ def multiview_server(
9393
app: Optionally provide a prexisting application to register to
9494
9595
Returns:
96-
The server instance and a function for adding views.
97-
See :func:`idom.widgets.common.multiview` for details.
96+
The server instance and a function for adding views. See
97+
:func:`idom.widgets.multiview` for details.
9898
"""
9999
mount, component = multiview()
100100

@@ -123,9 +123,9 @@ def hotswap_server(
123123
) -> Tuple[MountFunc, Server[_App]]:
124124
"""Set up a server where views can be dynamically swapped out.
125125
126-
In other words this allows the user to work with IDOM in an imperative manner.
127-
Under the hood this uses the :func:`idom.widgets.common.hotswap` function to
128-
swap the views on the fly.
126+
In other words this allows the user to work with IDOM in an imperative manner. Under
127+
the hood this uses the :func:`idom.widgets.hotswap` function to swap the views on
128+
the fly.
129129
130130
Parameters:
131131
server: The server type to start up as a daemon
@@ -137,8 +137,8 @@ def hotswap_server(
137137
sync_views: Whether to update all displays with newly mounted components
138138
139139
Returns:
140-
The server instance and a function for swapping views.
141-
See :func:`idom.widgets.common.hotswap` for details.
140+
The server instance and a function for swapping views. See
141+
:func:`idom.widgets.hotswap` for details.
142142
"""
143143
mount, component = hotswap(update_on_change=sync_views)
144144

src/idom/widgets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def World():
190190
Notebook where one might want multiple active views which can all be interacted
191191
with at the same time.
192192
193-
Refer to :func:`idom.server.imperative_server_mount` for a reference usage.
193+
See :func:`idom.server.prefab.multiview_server` for a reference usage.
194194
"""
195195
views: Dict[str, ComponentConstructor] = {}
196196

0 commit comments

Comments
 (0)