Skip to content

Commit

Permalink
Display type hints in API documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed Mar 16, 2022
1 parent 5efd39c commit 1aceed0
Show file tree
Hide file tree
Showing 25 changed files with 2,585 additions and 1,835 deletions.
58 changes: 56 additions & 2 deletions docs/_templates/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,61 @@

.. autoclass:: {{ objname }}

{% block methods %}
.. automethod:: __init__
{%- if methods %}
{% set constructor_methods = ['__init__'] %}
{%- for item in methods if item[0].isupper() %}
{{- constructor_methods.append(item)|default("", True) }}
{%- endfor %}

{% set special_methods = [] %}
{%- for item in methods if item.startswith('__') %}
{{- special_methods.append(item)|default("", True) }}
{%- endfor %}

{% set regular_methods = [] %}
{%- for item in methods if (not item[0].isupper() and not item.startswith('__')) %}
{{- regular_methods.append(item)|default("", True) }}
{%- endfor %}
{% endif %}

{% block constructor_methods %}
{% if constructor_methods %}
.. rubric:: {{ _('Constructors') }}
.. autosummary::
{% for item in constructor_methods %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block special_methods %}
{% if special_methods %}
.. rubric:: {{ _('Special Methods') }}
.. autosummary::
{% for item in special_methods|sort %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block regular_methods %}
{% if regular_methods %}
.. rubric:: {{ _('Methods') }}
.. autosummary::
{% for item in regular_methods %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block attributes %}
{% if attributes %}
.. rubric:: {{ _('Attributes') }}
.. autosummary::
{% for item in attributes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

.. automethod:: __init__
3 changes: 0 additions & 3 deletions docs/api/fec.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ This section contains classes and functions for constructing forward error corre
FEC classes
-----------

.. rubric::
.. autosummary::
:template: class.rst
:toctree:
Expand All @@ -19,7 +18,6 @@ FEC classes
Linear block code functions
---------------------------

.. rubric::
.. autosummary::
:toctree:

Expand All @@ -29,7 +27,6 @@ Linear block code functions
Cyclic code functions
---------------------

.. rubric::
.. autosummary::
:toctree:

Expand Down
32 changes: 23 additions & 9 deletions docs/api/galois-fields.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,31 @@ This section contains classes and functions for creating Galois field arrays.

.. currentmodule:: galois

Galois field class creation
---------------------------
Galois field classes
--------------------

Class factory functions
.......................

.. rubric:: Class factory functions
.. autosummary::
:toctree:

GF
Field

.. rubric:: Abstract base classes
Abstract base classes
.....................

.. autosummary::
:template: class.rst
:toctree:

FieldArray
FieldClass

.. rubric:: Pre-made Galois field classes
Pre-made Galois field array classes
...................................

.. autosummary::
:template: class_only_init.rst
:toctree:
Expand All @@ -33,7 +39,9 @@ Galois field class creation
Prime field functions
---------------------

.. rubric:: Primitive roots
Primitive roots
...............

.. autosummary::
:toctree:

Expand All @@ -44,15 +52,19 @@ Prime field functions
Extension field functions
-------------------------

.. rubric:: Irreducible polynomials
Irreducible polynomials
.......................

.. autosummary::
:toctree:

irreducible_poly
irreducible_polys
is_irreducible

.. rubric:: Primitive polynomials
Primitive polynomials
.....................

.. autosummary::
:toctree:

Expand All @@ -62,7 +74,9 @@ Extension field functions
matlab_primitive_poly
is_primitive

.. rubric:: Primitive elements
Primitive elements
..................

.. autosummary::
:toctree:

Expand Down
9 changes: 9 additions & 0 deletions docs/api/galois.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Classes
-------

.. autosummary::
:template: class.rst
:toctree:

BCH
Expand Down Expand Up @@ -101,3 +102,11 @@ Functions
square_free_factorization
totatives
trial_division

Types
-----

.. autosummary::
:toctree:

PolyLike
8 changes: 2 additions & 6 deletions docs/api/integer-factorization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ This section contains functions for factoring integers and analyzing their prope
Prime factorization
-------------------

.. rubric::
.. autosummary::
:toctree:

Expand All @@ -17,7 +16,6 @@ Prime factorization
Composite factorization
-----------------------

.. rubric::
.. autosummary::
:toctree:

Expand All @@ -27,7 +25,6 @@ Composite factorization
Specific factorization algorithms
---------------------------------

.. rubric::
.. autosummary::
:toctree:

Expand All @@ -36,10 +33,9 @@ Specific factorization algorithms
pollard_p1
pollard_rho

Integer tests
-------------
Tests
-----

.. rubric::
.. autosummary::
:toctree:

Expand Down
2 changes: 0 additions & 2 deletions docs/api/linear-sequences.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ This section contains classes and functions for creating and analyzing linear se
Linear-feedback shift registers
-------------------------------

.. rubric::
.. autosummary::
:template: class.rst
:toctree:
Expand All @@ -18,7 +17,6 @@ Linear-feedback shift registers
Sequence analysis functions
---------------------------

.. rubric::
.. autosummary::
:toctree:

Expand Down
3 changes: 0 additions & 3 deletions docs/api/number-theory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ This section contains functions for performing modular arithmetic and other numb
Divisibility
------------

.. rubric::
.. autosummary::
:toctree:

Expand All @@ -23,7 +22,6 @@ Divisibility
Congruences
-----------

.. rubric::
.. autosummary::
:toctree:

Expand All @@ -41,7 +39,6 @@ Congruences
Integer arithmetic
------------------

.. rubric::
.. autosummary::
:toctree:

Expand Down
30 changes: 22 additions & 8 deletions docs/api/polys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,27 @@ This section contains classes and functions for creating polynomials over Galois
Polynomial classes
------------------

.. rubric::
.. autosummary::
:template: class.rst
:toctree:

Poly

Special polynomials
-------------------

.. rubric:: Irreducible polynomials
Irreducible polynomials
.......................

.. autosummary::
:toctree:

irreducible_poly
irreducible_polys

.. rubric:: Primitive polynomials
Primitive polynomials
.....................

.. autosummary::
:toctree:

Expand All @@ -33,7 +37,9 @@ Special polynomials
conway_poly
matlab_primitive_poly

.. rubric:: Interpolating polynomials
Interpolating polynomials
.........................

.. autosummary::
:toctree:

Expand All @@ -42,7 +48,9 @@ Special polynomials
Polynomial functions
--------------------

.. rubric:: Divisibility
Divisibility
............

.. autosummary::
:toctree:

Expand All @@ -52,14 +60,18 @@ Polynomial functions
prod
are_coprime

.. rubric:: Congruences
Congruences
...........

.. autosummary::
:toctree:

pow
crt

.. rubric:: Polynomial factorization
Factorization
..............

.. autosummary::
:toctree:

Expand All @@ -68,7 +80,9 @@ Polynomial functions
distinct_degree_factorization
equal_degree_factorization

.. rubric:: Polynomial tests
Tests
.....

.. autosummary::
:toctree:

Expand Down
3 changes: 0 additions & 3 deletions docs/api/primes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ This section contains functions for generating primes and analyzing primality.
Prime number generation
-----------------------

.. rubric::
.. autosummary::
:toctree:

Expand All @@ -23,7 +22,6 @@ Prime number generation
Primality tests
---------------

.. rubric::
.. autosummary::
:toctree:

Expand All @@ -38,7 +36,6 @@ Primality tests
Specific primality tests
------------------------

.. rubric::
.. autosummary::
:toctree:

Expand Down
1 change: 0 additions & 1 deletion docs/api/transforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ This section contains classes and functions for various transforms using Galois
Number-theoretic transform
--------------------------

.. rubric::
.. autosummary::
:toctree:

Expand Down
Loading

0 comments on commit 1aceed0

Please sign in to comment.