GithubHelp home page GithubHelp logo

Comments (2)

Zac-HD avatar Zac-HD commented on July 20, 2024

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

  • maximum_signature_line_length makes signatures pretty ugly via readthedocs/sphinx_rtd_theme#1529 / readthedocs/sphinx_rtd_theme#1450.
    • I'd also want the blue shading to span the column, like an .. info:: box, rather than stopping at the signature width.
    • Both might be fixable with custom CSS downstream?
  • autodoc_type_aliases only works with from __future__ import annotations... i.e. PEP-563, which in Python 3.13 will be replaced by PEP-649. In any case, this is pretty painful - we'll want to have some way of post-processing the annotation strings and that'll probably need a custom Sphinx plugin (though not a huge one)
  • The type annotations get autolinked, which is fine, but then nitpicky mode complains that the type annotations aren't documented and this is pretty annoying.
    • Fortunately we can break out nitpick_ignore = [...] for whatever we don't want to document, such as typevars
    • There are also a few strings which just seem to be resolution errors.
  • maybe https://github.com/tox-dev/sphinx-autodoc-typehints would be helpful, going to see if I can get away without it first

from hypothesis.

Zac-HD avatar Zac-HD commented on July 20, 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, ...]]",
+    ),
+]

from hypothesis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.