Skip to content

Commit 87817fc

Browse files
committed
update doc formatting
1 parent 796188a commit 87817fc

20 files changed

+415
-43
lines changed

Diff for: docs/conf.py

+44-5
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,24 @@
1414
#
1515
import os
1616
import sys
17+
import inspect
1718

1819
sys.path.insert(0, os.path.abspath(".."))
20+
import numpy_ml
1921

2022

23+
gh_url = "https://github.com/ddbourgin/numpy-ml"
24+
2125
# -- Project information -----------------------------------------------------
2226

2327
project = "numpy-ml"
2428
copyright = "2019, David Bourgin"
2529
author = "David Bourgin"
2630

2731
# The short X.Y version
28-
version = ""
32+
version = "0.1"
2933
# The full version, including alpha/beta/rc tags
30-
release = ""
34+
release = "0.1.0"
3135

3236

3337
# -- General configuration ---------------------------------------------------
@@ -47,12 +51,46 @@
4751
"sphinx.ext.coverage",
4852
"sphinx.ext.mathjax",
4953
"sphinx.ext.ifconfig",
50-
"sphinx.ext.viewcode",
5154
"sphinx.ext.githubpages",
5255
"sphinx.ext.napoleon",
56+
"sphinx.ext.linkcode"
5357
# "numpydoc",
5458
]
5559

60+
# Try to link to source code on GitHub
61+
def linkcode_resolve(domain, info):
62+
if domain != "py":
63+
return None
64+
65+
module = info.get("module", None)
66+
fullname = info.get("fullname", None)
67+
68+
if not module or not fullname:
69+
return None
70+
71+
obj = sys.modules.get(module, None)
72+
if obj is None:
73+
return None
74+
75+
for part in fullname.split("."):
76+
obj = getattr(obj, part)
77+
if isinstance(obj, property):
78+
obj = obj.fget
79+
80+
try:
81+
file = inspect.getsourcefile(obj)
82+
if file is None:
83+
return None
84+
except:
85+
return None
86+
87+
file = os.path.relpath(file, start=os.path.dirname(numpy_ml.__file__))
88+
source, line_start = inspect.getsourcelines(obj)
89+
line_end = line_start + len(source) - 1
90+
filename = f"numpy_ml/{file}#L{line_start}-L{line_end}"
91+
return f"{gh_url}/blob/master/{filename}"
92+
93+
5694
# Napoleon settings
5795
# https://sphinxcontrib-napoleon.readthedocs.io/en/latest/sphinxcontrib.napoleon.html#sphinxcontrib.napoleon.Config
5896
napoleon_google_docstring = False
@@ -136,13 +174,14 @@
136174
}
137175

138176
html_theme_options = {
139-
# 'logo': 'logo.png',
140177
"github_user": "ddbourgin",
141178
"github_repo": "numpy-ml",
142179
"description": "Machine learning, in NumPy",
143-
# 'analytics_id': "", XXX: TODO
144180
"github_button": True,
145181
"show_powered_by": False,
182+
"fixed_sidebar": True,
183+
"analytics_id": "UA-65839510-3",
184+
# 'logo': 'logo.png',
146185
}
147186

148187

Diff for: docs/index.rst

+17-8
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,25 @@ Welcome to numpy-ml
44
tools written exclusively in `NumPy`_ and the Python `standard library`_.
55

66
The purpose of the project is to provide reference implementations of common
7-
machine learning components for rapid prototyping and experimentation.
7+
machine learning components for rapid prototyping and experimentation. With
8+
that in mind, don't just read the docs -- read the source!
89

910
.. _numpy-ml: http://www.github.com/ddbourgin/numpy-ml
1011
.. _NumPy: http://numpy.scipy.org/
1112
.. _standard library: https://docs.python.org/3/library/
1213

13-
API Reference
14-
-------------
14+
.. topic:: This documentation is under development!
15+
16+
We're working to expand our coverage. During this time there are likely to
17+
be typos, bugs, and poorly-worded sections. If you encounter any of the
18+
above, please file an `issue`_ or submit a `pull request`_!
19+
20+
.. _issue: https://github.com/ddbourgin/numpy-ml/issues
21+
.. _pull request: https://github.com/ddbourgin/numpy-ml/pulls
22+
1523
.. toctree::
1624
:maxdepth: 3
25+
:hidden:
1726

1827
numpy_ml.hmm
1928

@@ -23,20 +32,20 @@ API Reference
2332

2433
numpy_ml.ngram
2534

26-
numpy_ml.trees
35+
numpy_ml.rl_models
2736

28-
numpy_ml.utils
37+
numpy_ml.nonparametric
2938

30-
numpy_ml.rl_models
39+
numpy_ml.trees
3140

3241
numpy_ml.neural_nets
3342

3443
numpy_ml.linear_models
3544

36-
numpy_ml.nonparametric
37-
3845
numpy_ml.preprocessing
3946

47+
numpy_ml.utils
48+
4049
##########
4150
Disclaimer
4251
##########

Diff for: docs/numpy_ml.gmm.gmm.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
``GMM``
22
-------
33

4-
.. autoclass:: numpy_ml.gmm.gmm.GMM
4+
.. autoclass:: numpy_ml.gmm.GMM
55
:members:
66
:undoc-members:
77
:inherited-members:

Diff for: docs/numpy_ml.gmm.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ algorithm`_ to learn the GMM parameters.
5353

5454
.. topic:: References
5555

56-
.. [1] w.
56+
.. [1] Bilmes, J. A. (1998). "A gentle tutorial of the EM algorithm and its
57+
application to parameter estimation for Gaussian mixture and hidden
58+
Markov models" *International Computer Science Institute, 4(510)*
59+
https://www.inf.ed.ac.uk/teaching/courses/pmr/docs/EM.pdf
5760
5861
5962
.. toctree::

Diff for: docs/numpy_ml.hmm.MultinomialHMM.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
``MultinomialHMM``
22
------------------
33

4-
.. autoclass:: numpy_ml.hmm.hmm.MultinomialHMM
4+
.. autoclass:: numpy_ml.hmm.MultinomialHMM
55
:members:
66
:undoc-members:
77
:inherited-members:
8-
:show-inheritance:

Diff for: docs/numpy_ml.lda.lda.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
``LDA``
22
=======
33

4-
.. autoclass:: numpy_ml.lda.lda.LDA
4+
.. autoclass:: numpy_ml.lda.LDA
55
:members:
66
:undoc-members:
77
:inherited-members:

Diff for: docs/numpy_ml.lda.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ under the smoothed LDA model is:
6161
.. topic:: References
6262

6363
.. [1] Blei, Ng, & Jordan (2003). "Latent Dirichlet allocation". *Journal of
64-
Machine Learning Research*, 3, 993–1022.
64+
Machine Learning Research*, *3*, 993–1022.
65+
.. [2] Griffiths & Steyvers (2004). "Finding scientific topics". *PNAS*,
66+
*101(1)*, 5228-5235.
6567
6668
.. toctree::
6769
:maxdepth: 3

Diff for: docs/numpy_ml.lda.smoothed_lda.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
``SmoothedLDA``
22
===============
33

4-
.. autoclass:: numpy_ml.lda.lda_smoothed.SmoothedLDA
4+
.. autoclass:: numpy_ml.lda.SmoothedLDA
55
:members:
66
:undoc-members:
77
:inherited-members:

0 commit comments

Comments
 (0)