-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add inline classes to example docs (#598)
We need to support these better in the new Qiskit docs, so it's helpful to see how qiskit-sphinx-theme handles things. See Qiskit/documentation#199 for more context.
1 parent
9fd9765
commit 418231e
Showing
7 changed files
with
107 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from __future__ import annotations | ||
|
||
|
||
class SimpleInlineClass: | ||
"""This is a simple class that does not have | ||
any methods or attributes. | ||
It only has the class description and constructor. | ||
Many classes in Qiskit docs are simple like this. | ||
""" | ||
|
||
def __init__(self, arg1: str) -> None: | ||
self.arg1 = arg1 | ||
|
||
|
||
class InlineClassWithMethods: | ||
"""This class is more involved. | ||
Note how the methods and attributes are rendered and | ||
indented when this class is inlined on the docs page. | ||
""" | ||
|
||
CLASS_ATTRIBUTE: str = "An important part of any API." | ||
|
||
@property | ||
def interest_rate(self): | ||
pass | ||
|
||
def method1(self) -> int: | ||
"""A simple method.""" | ||
return 0 | ||
|
||
def method2( | ||
self, arg1: int | float, arg2: list[InlineClassWithMethods], description: str | ||
) -> tuple[int, InlineClassWithMethods]: | ||
"""A method with a lot of args! | ||
This method will use a Hamiltonian to reach quantum advantage. Hamilton: great play & the | ||
secret to quantum computing. What a polymath. | ||
Args: | ||
arg1: All numbers accepted. | ||
arg2: A list of other instances, although these will be discarded. | ||
description: If your description is too boring or too cryptic, this program | ||
will crash your computer. | ||
""" | ||
return [0, self] | ||
|
||
|
||
class CustomException(Exception): | ||
"""See how exceptions render too.""" |
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
============== | ||
Inline classes | ||
============== | ||
|
||
This is a page to test out how we render classes and functions | ||
included inline in the page. This is common with module pages. | ||
|
||
|
||
Important APIs | ||
============== | ||
|
||
Every time you use this program, you'll want to create an instance of | ||
:class:`api_example.inline_classes.SimpleInlineClass`. It has a simple interface: | ||
|
||
.. autoclass:: api_example.inline_classes.SimpleInlineClass | ||
|
||
It can be useful to use free functions rather than the class: | ||
|
||
.. autofunction:: api_example.my_function | ||
:noindex: | ||
|
||
Sometimes, you even need to use a really complex class! | ||
|
||
.. autoclass:: api_example.inline_classes.InlineClassWithMethods | ||
:no-members: | ||
:show-inheritance: | ||
|
||
.. rubric:: Attributes | ||
|
||
.. autoattribute:: CLASS_ATTRIBUTE | ||
.. autoattribute:: interest_rate | ||
|
||
.. rubric:: Methods | ||
|
||
.. automethod:: method1 | ||
.. automethod:: method2 | ||
|
||
|
||
Warning: exceptions | ||
------------------- | ||
|
||
The above APIs might raise an exception! Be careful! | ||
|
||
.. autoexception:: api_example.inline_classes.CustomException | ||
|
||
Other prose | ||
=========== | ||
|
||
Blah blah blah. |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5.07 KB
(110%)
...s/js/tests.js-snapshots/inline-table-of-contents-have-correct-fonts-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+993 Bytes
(100%)
tests/js/tests.js-snapshots/left-side-bar-renders-correctly-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.