Skip to content

Commit

Permalink
got recursive docs generation working
Browse files Browse the repository at this point in the history
  • Loading branch information
aryamanarora committed Jul 13, 2024
1 parent 589d0a5 commit ffdaae6
Show file tree
Hide file tree
Showing 13 changed files with 128 additions and 248 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ instance/
# Sphinx documentation
docs/_build/
docs/build/
docs/source/api/pyvene*

# PyBuilder
target/
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ sphinx:
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: requirements.txt
- requirements: docs/requirements.txt
4 changes: 2 additions & 2 deletions Makefile → docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = docs/source
BUILDDIR = docs/build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
Expand Down
4 changes: 2 additions & 2 deletions make.bat → docs/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=docs/source
set BUILDDIR=docs/build
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
Expand Down
6 changes: 6 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

sphinx>=6.0.0,<7.3.0
sphinx-book-theme>=1.0.1
sphinx-collections>=0.0.1
myst-nb>=1.0.0
myst-parser>=3.0.1
31 changes: 31 additions & 0 deletions docs/source/_templates/pv-class.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{ fullname | escape | underline}}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}
:members:
:show-inheritance:

{% block methods %}
.. automethod:: __init__

{% if methods %}
.. rubric:: {{ _('Methods') }}

.. autosummary::
{% for item in methods %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block attributes %}
{% if attributes %}
.. rubric:: {{ _('Attributes') }}

.. autosummary::
{% for item in attributes %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
66 changes: 66 additions & 0 deletions docs/source/_templates/pv-module.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{{ fullname | escape | underline}}

.. automodule:: {{ fullname }}

{% block attributes %}
{% if attributes %}
.. rubric:: Module Attributes

.. autosummary::
:toctree:
{% for item in attributes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block functions %}
{% if functions %}
.. rubric:: {{ _('Functions') }}

.. autosummary::
:toctree:
{% for item in functions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block classes %}
{% if classes %}
.. rubric:: {{ _('Classes') }}

.. autosummary::
:toctree:
:template: pv-class.rst
{% for item in classes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block exceptions %}
{% if exceptions %}
.. rubric:: {{ _('Exceptions') }}

.. autosummary::
:toctree:
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block modules %}
{% if modules %}
.. rubric:: Modules

.. autosummary::
:toctree:
:template: pv-module.rst
:recursive:
{% for item in modules %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
87 changes: 7 additions & 80 deletions docs/source/api/core.rst
Original file line number Diff line number Diff line change
@@ -1,87 +1,14 @@
``pyvene``: Core API
=========================================

.. module:: pyvene
.. currentmodule:: pyvene
.. automodule:: pyvene

.. toctree::
:hidden:

interventions
wrappers
models


Core model wrappers
-------------------

Whenever we want to wrap a model with intervention capabilities, the following classes are used:

.. autosummary::

IntervenableConfig
RepresentationConfig
IntervenableModel
IntervenableNdifModel
build_intervenable_model

Interventions
-------------

Pyvene supports many types of interventions out-of-the-box. They are:
.. rubric:: Modules

.. autosummary::
CollectIntervention
ZeroIntervention
VanillaIntervention
AdditionIntervention
SubtractionIntervention
NoiseIntervention
RotatedSpaceIntervention
BoundlessRotatedSpaceIntervention
SigmoidMaskRotatedSpaceIntervention
LowRankRotatedSpaceIntervention
PCARotatedSpaceIntervention
SigmoidMaskIntervention
AutoencoderIntervention

Additionally, we have abstract classes that you may use to create your own interventions:
:toctree:
:template: pv-module.rst
:recursive:

.. autosummary::
Intervention
LocalistRepresentationIntervention
DistributedRepresentationIntervention
TrainableIntervention
ConstantSourceIntervention
SourcelessIntervention
BasisAgnosticIntervention
SharedWeightsTrainableIntervention
SkipIntervention


Built-in model types
--------------------

Pyvene supports many types of models out-of-the-box. There are two dictionaries which
record useful information about these models:

.. autosummary::
type_to_module_mapping
type_to_dimension_mapping

We provide the following model types with unified helper names for their internal components:

.. autosummary::
create_gpt2
create_gpt2_lm
create_blip
create_blip_itm
create_gpt_neo
create_gpt_neox
create_gru
create_gru_lm
create_gru_classifier
create_llava
create_llama
create_mlp_classifier
create_backpack_gpt2
pyvene.data_generators
pyvene.models
95 changes: 0 additions & 95 deletions docs/source/api/interventions.rst

This file was deleted.

31 changes: 0 additions & 31 deletions docs/source/api/models.rst

This file was deleted.

20 changes: 0 additions & 20 deletions docs/source/api/wrappers.rst

This file was deleted.

Loading

0 comments on commit ffdaae6

Please sign in to comment.