Skip to content

Commit

Permalink
Sphinx apidocs: fix crosslink issues, polish rx.Observable (#419)
Browse files Browse the repository at this point in the history
* Remove 'copyright' (ends up double in generated docs)

* Add docstrings to core.typing, include it in API reference

* Fix crosslink issues in sphinx apidocs

* Polish docstring for rx.core.observable.Observable

* Re-order methods in Observable for nicer apidoc
  • Loading branch information
erikkemperman committed Jun 7, 2019
1 parent 862f3cb commit 26d9a3d
Show file tree
Hide file tree
Showing 8 changed files with 329 additions and 118 deletions.
33 changes: 33 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,39 @@
'exclude-members': '__dict__,__weakref__'
}


# Hack to get crosslinks working where things are available (and referred to) by
# several paths. E.g. we export rx.Observable but that's not its fully qualified
# name, and this causes the automatically generated links to fail for the
# argument / return types of functions (e.g. as defined in rx/__init__.py).
#
# It looks as though the intention of sphinx_autodoc_typehints is to include
# support for something like this in a future version:
#
# https://github.com/agronholm/sphinx-autodoc-typehints/issues/38

import sphinx_autodoc_typehints

qualname_overrides = {
'rx.core.observable.observable.Observable': 'rx.Observable'
}

_format_annotation = sphinx_autodoc_typehints.format_annotation


def format_annotation(annotation):
if isinstance(annotation, type):
full_name = f'{annotation.__module__}.{annotation.__qualname__}'
override = qualname_overrides.get(full_name)
if override is not None:
return f':py:class:`~{override}`'
return _format_annotation(annotation)

sphinx_autodoc_typehints.format_annotation = format_annotation

# End hack.


# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

Expand Down
1 change: 1 addition & 0 deletions docs/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Reference
Subject <reference_subject>
Scheduler <reference_scheduler>
Operators <reference_operators>
Typing <reference_typing>
2 changes: 1 addition & 1 deletion docs/reference_observable_factory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Observable Factory
=====================

.. automodule:: rx
:members:
:members:
2 changes: 1 addition & 1 deletion docs/reference_operators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Operators
=========

.. automodule:: rx.operators
:members:
:members:
7 changes: 7 additions & 0 deletions docs/reference_typing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. _reference_typing:

Typing
=======

.. automodule:: rx.core.typing
:members:
2 changes: 1 addition & 1 deletion project.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version = 3.0.0b4
description = Reactive Extensions (Rx) for Python
author = Dag Brattli
author_email = dag@brattli.net
copyright = Copyright 2013-2019, Dag Brattli, Microsoft Corp., and Contributors
copyright = 2013-2019, Dag Brattli, Microsoft Corp., and Contributors
license = MIT License
url = http://reactivex.io
download_url = https://github.com/ReactiveX/RxPY

0 comments on commit 26d9a3d

Please sign in to comment.