Skip to content

Commit be21616

Browse files
committed
change to doctest setup in sphinx
1 parent e8aac1b commit be21616

File tree

4 files changed

+113
-60
lines changed

4 files changed

+113
-60
lines changed

docs/.DS_Store

0 Bytes
Binary file not shown.

docs/source/conf.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"sphinx.ext.viewcode",
3232
"sphinx.ext.autodoc",
3333
"sphinx.ext.todo",
34-
# "sphinx_copybutton",
34+
"sphinx_copybutton",
3535
"sphinx.ext.doctest",
3636
"matplotlib.sphinxext.plot_directive",
3737
]
@@ -55,6 +55,10 @@
5555
templates_path = ["_templates"]
5656
exclude_patterns = []
5757

58+
#option for the copy button extension
59+
copybutton_prompt_text = r">>> |\.\.\. "
60+
copybutton_prompt_is_regexp = True
61+
5862
# -- Options for LaTeX output ------------------------------------------------
5963
latex_engine = "pdflatex"
6064
numfig = True

docs/source/usage.rst

+42-24
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,57 @@ Example 1 - Create a pile
1717

1818
A pile can be created in the simple following way in openpile.
1919

20-
.. code-block:: python
21-
22-
from openpile.construct import Pile
20+
.. doctest::
2321

24-
# Create a pile instance with two sections of respectively 10m and 30m length.
25-
pile = Pile(name = "",
26-
kind='Circular',
27-
material='Steel',
28-
top_elevation = 0,
29-
pile_sections={
30-
'length':[10,30],
31-
'diameter':[7.5,7.5],
32-
'wall thickness':[0.07, 0.08],
33-
}
34-
)
22+
>>> # import the Pile object from the construct module
23+
>>> from openpile.construct import Pile
24+
25+
>>> # Create a Pile
26+
>>> pile = Pile(name = "",
27+
... kind='Circular',
28+
... material='Steel',
29+
... top_elevation = 0,
30+
... pile_sections={
31+
... 'length':[10,30],
32+
... 'diameter':[7.5,7.5],
33+
... 'wall thickness':[0.07, 0.08],
34+
... }
35+
... )
36+
37+
>>> # Print the pile data
38+
>>> print(pile) # doctest: +NORMALIZE_WHITESPACE
39+
Elevation [m] Diameter [m] Wall thickness [m] Area [m2] I [m4]
40+
0 0.0 7.5 0.07 1.633942 11.276204
41+
1 -10.0 7.5 0.07 1.633942 11.276204
42+
2 -10.0 7.5 0.08 1.864849 12.835479
43+
3 -40.0 7.5 0.08 1.864849 12.835479
44+
>>>
3545

3646
Additional methods can be used to create a Pile, these methods can shorten the lines of codes needed to create the pile.
3747
For instance:
3848

39-
* :py:meth:`openpile.construct.Pile.create_tubular` which creates a circular pile of constant diameter.
49+
50+
.. doctest::
51+
52+
>>> # Import Pile object from constuct module
53+
>>> from openpile.construct import Pile
54+
55+
>>> # create pile
56+
>>> p = Pile.create_tubular(
57+
... name="<pile name>", top_elevation=0, bottom_elevation=-40, diameter=10, wt=0.050
58+
... )
59+
60+
>>> print(p)
61+
Elevation [m] Diameter [m] Wall thickness [m] Area [m2] I [m4]
62+
0 0.0 10.0 0.05 1.562942 19.342388
63+
1 -40.0 10.0 0.05 1.562942 19.342388
64+
>>>
65+
66+
4067

4168
Once the pile (object) is created, the user can use its properties and methods to interact with it.
4269
A simple view of the pile can be extracted by printing the object as below:
4370

44-
.. code-block:: python
45-
46-
# Print the pile data
47-
print(pile)
48-
Elevation [m] Diameter [m] Wall thickness [m] Area [m2] I [m4]
49-
0 0.0 7.5 0.07 1.633942 11.276204
50-
1 -10.0 7.5 0.07 1.633942 11.276204
51-
2 -10.0 7.5 0.08 1.864849 12.835479
52-
3 -40.0 7.5 0.08 1.864849 12.835479
5371

5472
The user can also extract easily the pile length, elevations and other properties.
5573
Please see the :py:class:`openpile.construct.Pile`

requirements.txt

+66-35
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,122 @@
1-
alabaster==0.7.12
1+
alabaster==0.7.13
2+
anyio==3.6.2
3+
appnope==0.1.3
4+
argon2-cffi==21.3.0
5+
argon2-cffi-bindings==21.2.0
26
attrs==22.2.0
3-
Babel==2.11.0
7+
autodoc-pydantic==1.9.0
8+
Babel==2.12.1
49
backcall==0.2.0
10+
beautifulsoup4==4.12.2
511
black==22.12.0
12+
bleach==6.0.0
613
cachetools==5.3.0
714
certifi==2022.12.7
15+
cffi==1.15.1
816
chardet==5.1.0
9-
charset-normalizer==2.1.1
17+
charset-normalizer==3.1.0
1018
click==8.1.3
1119
colorama==0.4.6
12-
coverage==7.2.1
20+
coverage==7.2.2
1321
cycler==0.11.0
14-
debugpy==1.6.4
22+
debugpy==1.6.6
1523
decorator==5.1.1
1624
defusedxml==0.7.1
1725
distlib==0.3.6
18-
docutils==0.17.1
26+
docutils==0.18.1
1927
entrypoints==0.4
20-
exceptiongroup==1.1.0
21-
filelock==3.10.6
22-
flake8==5.0.4
23-
flake8-black==0.3.6
28+
exceptiongroup==1.1.1
29+
fastjsonschema==2.16.3
30+
filelock==3.10.7
2431
fonttools==4.38.0
25-
fpdf2==2.6.0
32+
fpdf2==2.7.1
2633
idna==3.4
2734
imagesize==1.4.1
28-
importlib-metadata==6.0.0
35+
importlib-metadata==6.1.0
36+
importlib-resources==5.12.0
2937
iniconfig==2.0.0
3038
ipykernel==6.16.2
3139
ipython==7.34.0
40+
ipython-genutils==0.2.0
3241
jedi==0.18.2
3342
Jinja2==3.1.2
34-
jupyter_client==7.4.8
35-
jupyter_core==4.12.0
43+
jsonschema==4.17.3
44+
jupyter-client==7.4.9
45+
jupyter-core==4.12.0
46+
jupyter-server==1.24.0
47+
jupyterlab-pygments==0.2.2
3648
kiwisolver==1.4.4
37-
line-profiler==4.0.3
3849
llvmlite==0.39.1
39-
MarkupSafe==2.1.1
50+
MarkupSafe==2.1.2
4051
matplotlib==3.5.3
4152
matplotlib-inline==0.1.6
42-
mccabe==0.7.0
53+
mistune==2.0.5
4354
mypy-extensions==1.0.0
55+
nbclassic==0.5.5
56+
nbclient==0.7.3
57+
nbconvert==7.3.1
58+
nbformat==5.8.0
4459
nest-asyncio==1.5.6
60+
notebook==6.5.4
61+
notebook-shim==0.2.2
4562
numba==0.56.4
4663
numpy==1.21.6
47-
-e git+https://github.com/TchilDill/openpile.git
64+
-e git+https://github.com/TchilDill/openpile.git@e8aac1b7152a3ccbf6955d7df6f435d7f1ea753a#egg=openpile
4865
packaging==23.0
4966
pandas==1.3.5
67+
pandocfilters==1.5.0
5068
parso==0.8.3
5169
pathspec==0.11.1
70+
pexpect==4.8.0
5271
pickleshare==0.7.5
53-
Pillow==9.4.0
72+
Pillow==9.5.0
73+
pkgutil-resolve-name==1.3.10
5474
platformdirs==3.2.0
5575
pluggy==1.0.0
56-
prompt-toolkit==3.0.36
76+
prometheus-client==0.16.0
77+
prompt-toolkit==3.0.38
5778
psutil==5.9.4
58-
pycodestyle==2.9.1
59-
pydantic==1.10.4
60-
pyflakes==2.5.0
79+
ptyprocess==0.7.0
80+
pycparser==2.21
81+
pydantic==1.10.7
6182
Pygments==2.14.0
6283
pyparsing==3.0.9
63-
pyproject_api==1.5.1
64-
pytest==7.2.0
84+
pyproject-api==1.5.1
85+
pyrsistent==0.19.3
86+
pytest==7.2.2
6587
pytest-cov==4.0.0
88+
pytest-sphinx==0.5.0
6689
python-dateutil==2.8.2
67-
pytz==2022.7
68-
pywin32==305
90+
pytz==2023.3
6991
pyzmq==24.0.1
70-
requests==2.28.1
92+
requests==2.28.2
7193
scipy==1.7.3
94+
Send2Trash==1.8.0
7295
six==1.16.0
96+
sniffio==1.3.0
7397
snowballstemmer==2.2.0
74-
Sphinx==5.3.0
75-
sphinx-rtd-theme==1.1.1
98+
soupsieve==2.4
99+
sphinx==5.3.0
100+
sphinx-copybutton==0.5.2
101+
sphinx-rtd-theme==1.3.0
76102
sphinxcontrib-applehelp==1.0.2
77103
sphinxcontrib-devhelp==1.0.2
78104
sphinxcontrib-htmlhelp==2.0.0
105+
sphinxcontrib-jquery==4.1
79106
sphinxcontrib-jsmath==1.0.1
80107
sphinxcontrib-qthelp==1.0.3
81108
sphinxcontrib-serializinghtml==1.1.5
109+
terminado==0.17.1
110+
tinycss2==1.2.1
82111
tomli==2.0.1
83112
tornado==6.2
84113
tox==4.4.8
85-
traitlets==5.8.0
114+
traitlets==5.9.0
86115
typed-ast==1.5.4
87-
typing_extensions==4.5.0
88-
urllib3==1.26.13
116+
typing-extensions==4.5.0
117+
urllib3==1.26.15
89118
virtualenv==20.21.0
90-
wcwidth==0.2.5
91-
zipp==3.11.0
119+
wcwidth==0.2.6
120+
webencodings==0.5.1
121+
websocket-client==1.5.1
122+
zipp==3.15.0

0 commit comments

Comments
 (0)