Skip to content

Commit 0b26d9f

Browse files
committed
docs: change sphinx configuration
Jupyter Notebooks from examples can be used in docs
1 parent 22d2eaa commit 0b26d9f

File tree

16 files changed

+427
-313
lines changed

16 files changed

+427
-313
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{ fullname | escape | underline}}
2+
3+
.. currentmodule:: {{ module }}
4+
5+
.. autoclass:: {{ objname }}
6+
7+
{% block members %}
8+
{% if members %}
9+
.. rubric:: {{ _('Methods & Attributes') }}
10+
11+
.. autosummary::
12+
:toctree:
13+
:caption: Methods & Attributes
14+
{% for item in members %}
15+
{%- if not item.startswith('_') %}
16+
~{{ name }}.{{ item }}
17+
{%- endif -%}
18+
{%- endfor %}
19+
{% endif %}
20+
{% endblock %}

docs/conf.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# Configuration file for the Sphinx documentation builder.
22
#
3-
# This file only contains a selection of the most common options. For a full
4-
# list see the documentation:
5-
# https://www.sphinx-doc.org/en/master/usage/configuration.html
63

74
import os
85
import sys
@@ -44,14 +41,14 @@
4441
# The full version, including alpha/beta/rc tags.
4542
release = version
4643

44+
# -- General configuration ---------------------------------------------------
45+
4746
# The language for content autogenerated by Sphinx. Refer to documentation
4847
# for a list of supported languages.
4948
language = "en"
5049

51-
# -- General configuration ---------------------------------------------------
52-
53-
autodoc_default_flags = ["members"]
54-
autosummary_generate = ["index"]
50+
# The encoding of source files.
51+
source_encoding = "utf-8"
5552

5653
# Add any Sphinx extension module names here, as strings. They can be
5754
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
@@ -66,6 +63,7 @@
6663
"sphinx.ext.mathjax",
6764
"sphinx_rtd_theme",
6865
"nbsphinx",
66+
"nbsphinx_link",
6967
"recommonmark",
7068
# "myst_parser", # for markdown
7169
]
@@ -93,12 +91,14 @@
9391
# Theme options are theme-specific and customize the look and feel of a theme
9492
# further. For a list of options available for each theme, see the
9593
# documentation.
96-
# html_theme_options = {
97-
# "external_links": [],
98-
# # "github_url": "https://github.com/mbk-dev/okama",
99-
# # "twitter_url": "https://twitter.com/pandas_dev",
100-
# # "google_analytics_id": "UA-27880019-2",
101-
# }
94+
html_theme_options = {
95+
# "external_links": [],
96+
# "github_url": "https://github.com/mbk-dev/okama",
97+
# "google_analytics_id": "UA-27880019-2",
98+
# Toc options
99+
"titles_only": False,
100+
"navigation_depth": 4,
101+
}
102102

103103
# If false, no module index is generated.
104104
html_use_modindex = False
@@ -110,11 +110,16 @@
110110

111111
# -- Options for autodoc ------------------------------------------------
112112

113-
# This value controls how to represents typehints.
113+
autodoc_default_flags = ["members"]
114+
autodoc_default_options = {
115+
'undoc-members': False,
116+
'exclude-members': '__init__'}
114117
autodoc_typehints = "none"
115118
autodoc_member_order = "bysource"
116119
autoclass_content = "class" # to not insert __init__ docstrings
117120
autodoc_class_signature = "mixed" # Display the signature with the class name.
121+
autosummary_generate = True
122+
autosummary_imported_members = False
118123

119124
# -- Options for numpydoc ------------------------------------------------
120125
numpydoc_attributes_as_param_list = False
@@ -124,16 +129,20 @@
124129

125130
# -- Options for nbsphinx ------------------------------------------------
126131

132+
nbsphinx_execute_arguments = [
133+
"--InlineBackend.figure_formats={'svg', 'pdf'}",
134+
"--InlineBackend.rc=figure.dpi=96",
135+
]
127136
# nbsphinx do not use requirejs (breaks bootstrap)
128137
nbsphinx_requirejs_path = ""
129138

130-
# matplotlib plot directive settings
139+
# -- matplotlib plot directive settings -----------------------------------
131140
plot_html_show_formats = False
132141
plot_include_source = True
133142
plot_html_show_source_link = False
143+
plot_formats = [("png", 90)]
134144
plot_pre_code = """
135145
import numpy as np
136-
from matplotlib import pyplot as plt
137146
import okama as ok
138147
"""
139148

@@ -151,6 +160,3 @@
151160
# napoleon_use_rtype = True
152161
# napoleon_type_aliases = None
153162
# napoleon_attr_annotations = True
154-
155-
# The encoding of source files.
156-
source_encoding = "utf-8"

docs/index.rst

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<img src="https://img.shields.io/badge/python-v3-brightgreen.svg"
1111
alt="python"></a> &nbsp;
1212
<a href="https://pypi.org/project/okama/">
13-
<img src="https://img.shields.io/badge/pypi-v1.0.0-brightgreen.svg"
13+
<img src="https://img.shields.io/badge/pypi-v1.0.1-brightgreen.svg"
1414
alt="pypi"></a> &nbsp;
1515
<a href='https://coveralls.io/github/mbk-dev/okama?branch=master'>
1616
<img src='https://coveralls.io/repos/github/mbk-dev/okama/badge.svg?branch=master'
@@ -98,13 +98,28 @@ The latest development version can be installed directly from GitHub:
9898

9999
The development version of *okama* can have technical and financial issues. Please use carefully at your own risk.
100100

101-
Contents
102-
********
101+
102+
Classes Overview
103+
****************
104+
103105
.. toctree::
104-
:maxdepth: 1
106+
:maxdepth: 2
107+
:caption: Quick Start
108+
109+
quickstart
110+
111+
.. autosummary::
112+
:toctree: stubs
113+
:template: custom-class-template.rst
114+
:caption: Main Classes
115+
116+
okama.Asset
117+
okama.AssetList
118+
okama.Portfolio
119+
120+
121+
Indices and tables
122+
******************
105123

106-
source/asset_list
107-
source/portfolio
108-
source/single_period
109-
source/multi_period
110-
source/plots
124+
* :ref:`genindex`
125+
* :ref:`search`

docs/make.bat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
@ECHO OFF
2+
rem to remove everything from _build:
3+
rem make clean
4+
rem -E option is used to rebuild all
5+
rem make html -E
26

37
pushd %~dp0
48

docs/quickstart.nblink

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"path": "../examples/01 howto.ipynb"
3+
}

docs/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ sphinx>=4.1.2
22
sphinx_rtd_theme==0.5.2
33
numpydoc==1.1.0
44
nbsphinx==0.8.7
5+
nbsphinx-link>=1.3.0
6+
pandoc>=2.14.0
57
recommonmark==0.7.1
68
okama>=1.0.0

docs/rst.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
@ECHO OFF
2+
rem generate .rst sorce files
3+
14
sphinx-apidoc -o source/ ../okama

docs/source/asset_list.rst

Lines changed: 0 additions & 13 deletions
This file was deleted.

docs/source/multi_period.rst

Lines changed: 0 additions & 19 deletions
This file was deleted.

docs/source/plots.rst

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)