Skip to content

Commit

Permalink
Update docs (#159)
Browse files Browse the repository at this point in the history
* Update docs structure and fixup some docstrings

* Fix logo in docs
  • Loading branch information
Erotemic committed Aug 1, 2024
1 parent ad73357 commit b55981c
Show file tree
Hide file tree
Showing 38 changed files with 73 additions and 39 deletions.
File renamed without changes.
8 changes: 8 additions & 0 deletions docs/source/auto/xdoctest.__main__.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
xdoctest.\_\_main\_\_ module
============================

.. automodule:: xdoctest.__main__
:members:
:undoc-members:
:show-inheritance:
:private-members:
8 changes: 8 additions & 0 deletions docs/source/auto/xdoctest._tokenize.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
xdoctest.\_tokenize module
==========================

.. automodule:: xdoctest._tokenize
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.checker module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.constants module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.core module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.demo module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.directive module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.docstr.docscrape\_google module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.docstr.docscrape\_numpy module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ Module contents
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.doctest\_example module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.doctest\_part module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.dynamic\_analysis module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.exceptions module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.global\_state module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.parser module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.plugin module
:members:
:undoc-members:
:show-inheritance:
:private-members:
3 changes: 3 additions & 0 deletions docs/source/xdoctest.rst → docs/source/auto/xdoctest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Submodules
.. toctree::
:maxdepth: 4

xdoctest.__main__
xdoctest._tokenize
xdoctest.checker
xdoctest.constants
xdoctest.core
Expand All @@ -38,3 +40,4 @@ Module contents
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.runner module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.static\_analysis module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ Module contents
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.utils.util\_deprecation module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.utils.util\_import module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.utils.util\_misc module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.utils.util\_mixins module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.utils.util\_notebook module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.utils.util\_path module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.utils.util\_str module
:members:
:undoc-members:
:show-inheritance:
:private-members:
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ xdoctest.utils.util\_stream module
:members:
:undoc-members:
:show-inheritance:
:private-members:
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# need to edit the conf.py
cd ~/code/xdoctest/docs
sphinx-apidoc --private --separate -f -o ~/code/xdoctest/docs/source/auto ~/code/xdoctest/src/xdoctest '_tokenize.py'
sphinx-apidoc --private --separate --force --output-dir ~/code/xdoctest/docs/source/auto ~/code/xdoctest/src/xdoctest '_tokenize.py'
# Note: the module should importable before running this
# (e.g. install it in developer mode or munge the PYTHONPATH)
Expand Down
4 changes: 1 addition & 3 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
.. This file is no longer used, we redirect to autoapi/xdoctest/index.html
:github_url: https://github.com/Erotemic/xdoctest

.. The __init__ files contains the top-level documentation overview
Expand All @@ -10,7 +8,7 @@
:maxdepth: 8
:caption: Package Layout

xdoctest
auto/xdoctest


Indices and tables
Expand Down
File renamed without changes.
File renamed without changes.
19 changes: 9 additions & 10 deletions src/xdoctest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# :github_url: https://github.com/Erotemic/xdoctest
'''
.. The large version wont work because github strips rst image rescaling. https://i.imgur.com/AcWVroL.png
.. image:: https://camo.githubusercontent.com/505298c88719d26f35794319bbc39a522e674314/68747470733a2f2f692e696d6775722e636f6d2f7530745959784d2e706e67
.. The large version wont work because github strips rst image rescaling. https://i.imgur.com/u0tYYxM.png
.. image:: https://i.imgur.com/u0tYYxM.png
:height: 100px
:align: left
Expand Down Expand Up @@ -56,8 +56,9 @@
Getting Started 0: Installation
--------------------------------
First ensure that you have :doc:`Python installed <../../installing_python>` and
ideally are in a virtual environment. Install xdoctest using the pip.
First ensure that you have
:doc:`Python installed <../manual/installing_python>` and ideally are in a
virtual environment. Install xdoctest using the pip.
.. code:: bash
Expand Down Expand Up @@ -94,7 +95,6 @@ def fib(n):
a, b = b, a+b
print()
We can add a "doctest" in the "docstring" as both an example and a test of the
code. All we have to do is prefix the doctest code with three right chevrons
`` >>> ``. We can also use xdoctest directives to control the flow of doctest
Expand Down Expand Up @@ -127,10 +127,9 @@ def fib(n):
``xdoctest/__init__.py`` file, which is a Python file, that means we can write
doctests in it. If you have xdoctest installed, you can use the xdoctest cli
to execute the following code: ``xdoctest -m xdoctest.__init__ __doc__:0``.
Also notice that the previous code prefixed with ``>>> `` is skipped due to the
xdoctest ``SKIP`` :doc:`directive<xdoctest.directive>`. For more information on
directives see :doc:`the docs for the xdoctest directive
module<xdoctest.directive>`.
Also notice that the previous doctest is skipped due to the SKIP directive.
For more information on directives see
:doc:`the docs for the xdoctest directive module<auto/xdoctest.directive>`.
.. code:: python
Expand Down Expand Up @@ -305,7 +304,7 @@ def fib(n):
You can also run doctests
:doc:`inside Jupyter Notebooks <../xdoc_with_jupyter>`.
:doc:`inside Jupyter Notebooks <../manual/xdoc_with_jupyter>`.
'''


Expand Down
18 changes: 10 additions & 8 deletions src/xdoctest/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@
A doctest that uses stdout might look like this
>>> print('We expect this exact string')
We expect this exact string
.. code:: python
>>> print('We expect this exact string')
We expect this exact string
A doctest that uses a raw expression might look like this
>>> def foo():
>>> return 3
>>> foo()
3
.. code:: python
>>> def foo():
>>> return 3
>>> foo()
3
In most cases it is best to use stdout to write your got-want tests because it
is easier to control strings sent to stdout than it is to control the
representation of expression-based "got-strings".
"""
import re
import difflib
Expand Down
22 changes: 6 additions & 16 deletions src/xdoctest/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,19 @@
The following is a glossary of terms and jargon used in this repo.
* callname - the name of a callable function, method, class etc... e.g.
``myfunc``, ``MyClass``, or ``MyClass.some_method``.
* callname - the name of a callable function, method, class etc... e.g. ``myfunc``, ``MyClass``, or ``MyClass.some_method``.
* got / want - a test that produces stdout or a value to check. Whatever is
produced is what you "got" and whatever is expected is what you "want".
See :mod:`xdoctest.checker` for more details.
* got / want - a test that produces stdout or a value to check. Whatever is produced is what you "got" and whatever is expected is what you "want". See :mod:`xdoctest.checker` for more details.
* directives - special in-doctest comments that change the behavior of the
doctests at runtime. See :mod:`xdoctest.directive` for more details.
* directives - special in-doctest comments that change the behavior of the doctests at runtime. See :mod:`xdoctest.directive` for more details.
* chevrons - the three cheverons (``>>> ``) or right angle brakets are the
standard prefix for a doctest, also referred to as a PS1 line in the
parser.
* chevrons - the three cheverons (``>>> ``) or right angle brakets are the standard prefix for a doctest, also referred to as a PS1 line in the parser.
* zero-args - a function that can be called without any arguments.
* freeform style - This is the term used to refer to a doctest that could be
anywhere in the docstring. The alternative are structured doctests where
they are only expected in known positions like in "Example blocks" for
google and numpy style docstrings.
* freeform style - This is the term used to refer to a doctest that could be anywhere in the docstring. The alternative are structured doctests where they are only expected in known positions like in "Example blocks" for google and numpy style docstrings.
* TODO - complete this list (Make an issue or PR if there is any term you don't
immediately understand!).
* TODO - complete this list (Make an issue or PR if there is any term you don't immediately understand!).
"""
import sys
import textwrap
Expand Down
2 changes: 1 addition & 1 deletion src/xdoctest/doctest_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def format_src(self, linenos=True, colored=None, want=True,
offset_linenos (bool): if True offset line numbers to agree with
their position in the source text file (default False).
prefix (bool): if False, exclude the doctest `>>> ` prefix
prefix (bool): if False, exclude the doctest ``>>> `` prefix
Returns:
str
Expand Down

0 comments on commit b55981c

Please sign in to comment.