-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77c9949
commit b49e437
Showing
15 changed files
with
187 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .autoflex import AutoFlex | ||
from .flextree import FlexTree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import pydantic | ||
from docutils.parsers import rst | ||
from typing import Any | ||
|
||
|
||
class AutoFlex(rst.Directive): | ||
""" | ||
Extension of the ``.. automodule::`` directive. | ||
In order to mantain compatibility and extensibility with all the versions of pydantic, | ||
it makes sense that this tool uses, rather than the internal pydantic class representation of the class, | ||
the interconnected JSON definition of the data structure. From this generic data structure, the tool can | ||
generate the documentation in a way that is compatible with the version of pydantic that is being used, or even | ||
any generic data structure schema that can be generated from a given class definition. | ||
The idea is that we can use the ``autoflex`` directive to improve the data structure generated during the | ||
`autosummary` process instead of the `automodule` or `autoclass` directive. | ||
Usage | ||
----- | ||
.. code:: | ||
.. autoflex:: my_package.MyClass | ||
""" | ||
|
||
# Directive information | ||
has_content: bool = True | ||
|
||
# name: str = "autoflex" | ||
# arguments: Any = None | ||
# options: Any = None | ||
# content: Any = None | ||
# lineno: Any = None | ||
# content_offset: Any = None | ||
# block_text: Any = None | ||
# state: Any = None | ||
# state_machine: Any = None | ||
# reporter: Any = None | ||
# | ||
# required_arguments: int = 1 | ||
# optional_arguments: int = 0 | ||
|
||
def run(self): | ||
print("AutoFlex directive running.") | ||
print(self.name) | ||
return [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from sphinx.directives.other import TocTree | ||
|
||
|
||
class FlexTree(TocTree): | ||
""" | ||
Extension of the ``.. toctree::`` sphinx directive. | ||
Notes | ||
----- | ||
A customizable toctree directive with options to create | ||
links with descriptions, custom formatting, and interactive features. Ideally this feature should be developed | ||
in an extensible way building on top of the existing ``toctree`` directive. | ||
Usage | ||
----- | ||
The usage should be broadly compatible with the existing ``.. toctree::`` directive in the structures they represent. | ||
However, there is more flexibility in the way the tree is generated and the parameters that can be passed. | ||
To add descriptions below the given generated links, the following syntax can be used: | ||
.. code:: | ||
.. flextree:: | ||
:maxdepth: 2 | ||
mypage1/ | ||
:description: This is the description of the page. | ||
mypage2/ | ||
:description: This is the description of the page. | ||
""" | ||
|
||
# Directive information | ||
has_content: bool = True | ||
|
||
# name: str = "autoflex" | ||
# arguments: Any = None | ||
# options: Any = None | ||
# content: Any = None | ||
# lineno: Any = None | ||
# content_offset: Any = None | ||
# block_text: Any = None | ||
# state: Any = None | ||
# state_machine: Any = None | ||
# reporter: Any = None | ||
# | ||
# required_arguments: int = 1 | ||
# optional_arguments: int = 0 | ||
|
||
def run(self): | ||
print("Generating Flextree.") | ||
return super().run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Development | ||
=========== | ||
|
||
The Basics | ||
----------- | ||
|
||
Build the local documentation basically: | ||
|
||
.. code:: | ||
poetry run python -m sphinx docs/ _docs/ | ||
Guidelines | ||
---------- | ||
|
||
Note that the development of the project should aim to maximize the usage of the directives developed in this package. | ||
|
||
Note that because many of these directives are extending `sphinx`-specific ones, then we want to both mantain compatibility whilst guaranteeing extensibility. One way to approach this is by fixing the corresponding versions of Sphinx we support. We can then build upon the Sphinx directive classes by overwriting their class methods accordingly, depending on what needs to be edited. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
``autoflex`` | ||
============ | ||
|
||
One of the main complexities we have is that managing `rst` code blocks in docstrings is complicated. It involves manually writing and updating parameter descriptions rather than focusing on the actual docstrings. | ||
|
||
When we have multiple classes, and multiple inherited classes, it is hard to keep track of each code block and all the added parameters. For example, it would be possible to manually input parameters at each particular stage. However, it would be nice if this could be extracted directly out of each class declaration automatically and rendered in a nice way. | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.. flextree:: | ||
|
||
autoflex | ||
flextree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Usage Overview | ||
--------------- | ||
|
||
.. list-table:: | ||
:header-rows: 1 | ||
|
||
* - Extension Command | ||
- Brief Description | ||
- Specification | ||
* - ``flextree`` | ||
- A customizable toctree directive with options to create links with descriptions, custom formatting, and interactive features. | ||
- https://github.com/flexcompute/autoflex/issues/10 | ||
* - ``autoflex`` | ||
- Our very extensible, automatic API documentation generator for classes. | ||
- | ||
|
||
|
||
.. code:: rst | ||
.. flextree:: | ||
:maxdepth: 2 | ||
mypage1/ | ||
:description: This is the description of the page. | ||
mypage2/ | ||
:description: This is the description of the page. | ||
Basic Example: | ||
|
||
.. code:: rst | ||
.. autoflex:: somepackage.MyClass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Get Started | ||
=========== | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
def test_import(): | ||
from autoflex import AutoFlexDirective | ||
AutoFlexDirective() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import autoflex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +0,0 @@ | ||
|
||
def test_import(): | ||
assert sphinxcontrib.autoflex.install_verification() == True | ||