Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new Sphinx configuration options #3860

Closed
Zac-HD opened this issue Jan 25, 2024 · 2 comments · Fixed by #3868
Closed

Add new Sphinx configuration options #3860

Zac-HD opened this issue Jan 25, 2024 · 2 comments · Fixed by #3868
Labels
docs documentation could *always* be better

Comments

@Zac-HD
Copy link
Member

Zac-HD commented Jan 25, 2024

From this page on Sphinx configuration options, I think there are some new ones we should try out:

  • nitpicky = True to warn about more missing references. Also set the default_role to py:obj, which will ensure the most common cases work out after all. (main effect: CI will now warn when people use single instead of double-backticks for monospace)
  • needs_sphinx - dynamically load this from requirements/tools.txt so it stays up-to-date with our pins? We install from pins on readthedocs so this should work fine. Convert the == to >= so that checking out an old branch doesn't force a downgrade to build docs.
  • enable maximum_signature_line_length and python_... - going to one argument per line will enable us to show type annotations again (changing autodoc_typehints from none to signature); we'll also want to set autodoc_type_aliases and perhaps load this dynamically from the source code (matching on _: TypeAlias = _ lines - actually this would be a great feature to upstream!)
@Zac-HD Zac-HD added the docs documentation could *always* be better label Jan 25, 2024
@Zac-HD
Copy link
Member Author

Zac-HD commented Jan 31, 2024

Ooooh boy, getting nice docs for type annotations is going to be harder than I'd hoped.

@Zac-HD
Copy link
Member Author

Zac-HD commented Jan 31, 2024

OK, I'm just going to abandon the type-annotations part because I'm not sure whether it's net-positive for readers, and want to ship the rest of the stuff above quickly. If we revisit in future, you can jumpstart with:

 autodoc_member_order = "bysource"
-autodoc_typehints = "none"
+autodoc_typehints = "signature"
 maximum_signature_line_length = 60  # either one line, or one param per line
 
+nitpick_ignore = [
+    # CPython docs limitations
+    ("py:class", "module"),
+    ("py:class", "ellipsis"),
+    # TypeVars we don't want to document
+    ("py:class", "P"),
+    ("py:class", "hypothesis.core.TestFunc"),
+    ("py:class", "hypothesis.extra.array_api.DataType"),
+    ("py:class", "hypothesis.extra.django._fields.F"),
+    ("py:class", "hypothesis.extra.django._impl.ModelT"),
+    ("py:class", "hypothesis.extra.ghostwriter.X"),
+    ("py:class", "hypothesis.extra.ghostwriter.Y"),
+    ("py:class", "hypothesis.extra.numpy.D"),
+    ("py:class", "hypothesis.strategies._internal.strategies.Ex"),
+    ("py:class", "hypothesis.strategies._internal.strategies.Ex_Inv"),
+    ("py:class", "hypothesis.strategies._internal.strategies.T"),
+    # Other internal classes we don't want to document
+    ("py:class", "Verbosity"),
+    ("py:class", "hypothesis.extra._array_helpers.BroadcastableShapes"),
+    ("py:class", "hypothesis.stateful.Bundle"),
+    ("py:class", "hypothesis.stateful.MultipleResults"),
+    ("py:class", "hypothesis.stateful._OmittedArgument"),
+    ("py:class", "hypothesis.strategies._internal.core.RandomSeeder"),
+    ("py:class", "hypothesis.utils.conventions.UniqueIdentifier"),
+    # Random other issues
+    ("py:class", "hypothesis.strategies.SearchStrategy[numpy.typing.NDArray.~D]"),
+    (
+        "py:class",
+        "hypothesis.strategies.SearchStrategy[~typing.Tuple[numpy.typing.NDArray.~D, ...]]",
+    ),
+]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs documentation could *always* be better
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant