-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add inline classes to example docs #598
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol