Skip to content

Commit 9d28677

Browse files
authored
Merge pull request #203 from dpshelio/w6-fixes
Improvements for week 6
2 parents f7bf442 + 6eff6f4 commit 9d28677

File tree

4 files changed

+70
-29
lines changed

4 files changed

+70
-29
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
output-site
33
output
44
_site/
5+
build/
6+
workflow/
7+
vendor/
58
.sconsign.dblite
69
html/index.html
710
pdf
811
*.pyc
12+
*.nbconvert.ipynb
913
*.swp
1014
a.out
1115
html/reveal/.DS_Store

_config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ redcarpet:
2525
extensions: ["strikethrough","tables"]
2626

2727

28-
include:
29-
- "ch04packaging/greetings/doc/_static"
30-
- "ch04packaging/greetings/doc/_static"
31-
- "ch04packaging/greetings/doc/_modules"
28+
include: # NOTE: This is not a path, but the directories name, wherever they are
29+
- _static
30+
- _modules
31+
3232
exclude:
3333
- vendor/
3434
- Gemfile

ch02git/14Bisect.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"source": [
6363
"%%bash\n",
6464
"rm -rf bisectdemo\n",
65-
"git clone git@github.com:UCL-RITS/bisectdemo.git"
65+
"git clone https://github.com/UCL-RITS/bisectdemo.git"
6666
]
6767
},
6868
{

ch04packaging/04documentation.ipynb

Lines changed: 61 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,22 @@
6161
"together with the signature, into a web page.\n",
6262
"\n",
6363
"The most popular is [Doxygen](http://www.doxygen.nl/).\n",
64-
"[Have a look at an example of some Doxygen output](\n",
65-
"http://www.bempp.org/cppref/2.0/group__abstract__boundary__operators.html).\n",
6664
"\n",
67-
"[Sphinx](http://sphinx-doc.org/) is nice for Python, and works with C++ as well.\n",
68-
"Here's some [Sphinx-generated output](http://www.bempp.org/pythonref/2.0/bempp_visualization.html)\n",
69-
"and the [corresponding source code](https://bitbucket.org/bemppsolutions/bempp/src/8f10af0b0b4a94bc36c6236eb9ddb2a34cde1756/python/bempp/visualization.py?at=v2.0.2&fileviewer=file-view-default).\n",
70-
"[Breathe](https://breathe.readthedocs.io/en/latest/) can be used to make Sphinx and Doxygen work together.\n",
65+
"Here are some other documentation tools used in different languages, have a look at the generated and source examples:\n",
7166
"\n",
72-
"[Roxygen](https://cran.r-project.org/web/packages/roxygen2/vignettes/roxygen2.html) is good for R.\n"
67+
"\n",
68+
"| Language | Name | Output example | source |\n",
69+
"| --- | --- | --- | --- |\n",
70+
"| Multiple | [Doxygen](http://www.doxygen.nl/) | [`Array` docs](https://eigen.tuxfamily.org/dox/classEigen_1_1Array.html) | [`Array` docstring source](https://gitlab.com/libeigen/eigen/-/blob/55e3ae02ac1f13fbcc7a83f5e37a39fd2b142db1/Eigen/src/Core/Array.h#L26-L45) |\n",
71+
"| Python | [Sphinx](http://sphinx-doc.org/) | [`numpy.ones` docs](https://numpy.org/doc/1.21/reference/generated/numpy.ones.html) | [`numpy.ones` docstring source](https://github.com/numpy/numpy/blob/v1.21.0/numpy/core/numeric.py#L149-L206) |\n",
72+
"| R | [pkgdown](https://pkgdown.r-lib.org/) | [`stringr`'s `str_unique`](https://stringr.tidyverse.org/reference/str_unique.html) | [`stringr`'s `str_unique` docstring source](https://github.com/tidyverse/stringr/blob/main/R/unique.R) |\n",
73+
"| Julia | [Documnenter.jl](https://juliadocs.github.io/Documenter.jl/stable/) | [`ones` docs](https://docs.julialang.org/en/v1/base/arrays/#Base.ones) | [`ones` docstring source](https://github.com/JuliaLang/julia/blob/ae8452a9e0b973991c30f27beb2201db1b0ea0d3/base/array.jl#L475-L493) |\n",
74+
"| Fortan | [FORD](https://github.com/Fortran-FOSS-Programmers/ford) | [`arange` docs](https://stdlib.fortran-lang.org/interface/arange.html) | [`arange` docstring source](https://github.com/fortran-lang/stdlib/blob/d14fca8e7cc36ed5f6f84d2bf576c91c2e54eb07/src/stdlib_math.fypp#L276-L290) |\n",
75+
"| Rust | [rustdoc](https://doc.rust-lang.org/rustdoc/what-is-rustdoc.html) | [`Matrix` docs](https://docs.rs/nalgebra/0.18.0/nalgebra/base/struct.Matrix.html) | [`Matrix` docstring source](https://github.com/dimforge/nalgebra/blob/8ea8ac70d5ad4bae865e6246a48455bf0b3fa3d2/src/base/matrix.rs#L59-L157) |\n",
76+
"\n",
77+
"[Breathe](https://breathe.readthedocs.io/en/latest/) can be used to make Sphinx and Doxygen work together (good to keep documentation, for example, of a C++ project that includes Python bindings). [roxygen2](https://cran.r-project.org/web/packages/roxygen2/vignettes/roxygen2.html) is another good option for R packages.\n",
78+
"\n",
79+
"\n"
7380
]
7481
},
7582
{
@@ -95,8 +102,8 @@
95102
"There are various conventions for how to write docstrings, but the native Sphinx one doesn't look nice when used with\n",
96103
"the built in `help` system.\n",
97104
"\n",
98-
"In writing Greeter, we used the docstring conventions from NumPy.\n",
99-
"So we use the [numpydoc](https://numpydoc.readthedocs.io/en/latest/) sphinx extension to \n",
105+
"In writing Greeter, we used the [docstring conventions from NumPy](https://numpy.org/doc/stable/docs/howto_document.html).\n",
106+
"So we use the [`numpydoc`](https://numpydoc.readthedocs.io/en/latest/) sphinx extension to\n",
100107
"support these (Note: you will need to install this extension for the later examples to work)."
101108
]
102109
},
@@ -176,7 +183,7 @@
176183
"metadata": {},
177184
"source": [
178185
"```\n",
179-
"Welcome to the Sphinx 3.3.0 quickstart utility.\n",
186+
"Welcome to the Sphinx 4.2.0 quickstart utility.\n",
180187
"\n",
181188
"Please enter values for the following settings (just press Enter to\n",
182189
"accept a default value, if one is given in brackets).\n",
@@ -187,15 +194,41 @@
187194
"Either, you use a directory \"_build\" within the root path, or you separate\n",
188195
"\"source\" and \"build\" directories within the root path.\n",
189196
"> Separate source and build directories (y/n) [n]:\n",
197+
"\n",
198+
"The project name will occur in several places in the built documentation.\n",
199+
"> Project name: Greetings\n",
200+
"> Author name(s): James Hetherington\n",
201+
"> Project release []: 0.1\n",
202+
"\n",
203+
"If the documents are to be written in a language other than English,\n",
204+
"you can select a language here by its language code. Sphinx will then\n",
205+
"translate text that it generates into that language.\n",
206+
"\n",
207+
"For a list of supported codes, see\n",
208+
"https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-language.\n",
209+
"> Project language [en]:\n",
210+
"\n",
211+
"Creating file ./conf.py.\n",
212+
"Creating file ./index.rst.\n",
213+
"Creating file ./Makefile.\n",
214+
"Creating file ./make.bat.\n",
215+
"\n",
216+
"Finished: An initial directory structure has been created.\n",
217+
"\n",
218+
"You should now populate your master file /tmp/index.rst and create other documentation\n",
219+
"source files. Use the Makefile to build the docs, like so:\n",
220+
" make builder\n",
221+
"where \"builder\" is one of the supported builders, e.g. html, latex or linkcheck.\n",
190222
"```"
191223
]
192224
},
193225
{
194226
"cell_type": "markdown",
195227
"metadata": {},
196228
"source": [
197-
"and then look at and adapt the generated config, a file called\n",
198-
"conf.py in the root of the project. This contains the project's Sphinx configuration, as Python variables:"
229+
"and then look at and adapt the generated config - a file called\n",
230+
"`conf.py` in the root of the project - with, for example, the extensions we want to use.\n",
231+
"This config file contains the project's Sphinx configuration, as Python variables:"
199232
]
200233
},
201234
{
@@ -247,6 +280,9 @@
247280
"import sys\n",
248281
"import os\n",
249282
"\n",
283+
"# We need to tell Sphinx where to look for modules\n",
284+
"sys.path.insert(0, os.path.abspath('.'))\n",
285+
"\n",
250286
"extensions = [\n",
251287
" 'sphinx.ext.autodoc', # Support automatic documentation\n",
252288
" 'sphinx.ext.coverage', # Automatically check if functions are documented\n",
@@ -257,29 +293,30 @@
257293
"templates_path = ['_templates']\n",
258294
"source_suffix = '.rst'\n",
259295
"master_doc = 'index'\n",
260-
"project = u'Greetings'\n",
261-
"copyright = u'2014, James Hetherington'\n",
296+
"project = 'Greetings'\n",
297+
"copyright = '2014, James Hetherington'\n",
262298
"version = '0.1'\n",
263299
"release = '0.1'\n",
264-
"exclude_patterns = ['_build']\n",
300+
"exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']\n",
301+
"html_theme = 'alabaster'\n",
265302
"pygments_style = 'sphinx'\n",
266303
"htmlhelp_basename = 'Greetingsdoc'\n",
267304
"latex_elements = {\n",
268305
"}\n",
269306
"\n",
270307
"latex_documents = [\n",
271-
" ('index', 'Greetings.tex', u'Greetings Documentation',\n",
272-
" u'James Hetherington', 'manual'),\n",
308+
" ('index', 'Greetings.tex', 'Greetings Documentation',\n",
309+
" 'James Hetherington', 'manual'),\n",
273310
"]\n",
274311
"\n",
275312
"man_pages = [\n",
276-
" ('index', 'greetings', u'Greetings Documentation',\n",
277-
" [u'James Hetherington'], 1)\n",
313+
" ('index', 'greetings', 'Greetings Documentation',\n",
314+
" ['James Hetherington'], 1)\n",
278315
"]\n",
279316
"\n",
280317
"texinfo_documents = [\n",
281318
" ('index', 'Greetings', u'Greetings Documentation',\n",
282-
" u'James Hetherington', 'Greetings', 'One line description of project.',\n",
319+
" 'James Hetherington', 'Greetings', 'One line description of project.',\n",
283320
" 'Miscellaneous'),\n",
284321
"]"
285322
]
@@ -296,7 +333,7 @@
296333
"metadata": {},
297334
"source": [
298335
"\n",
299-
"Sphinx uses [RestructuredText](http://docutils.sourceforge.net/rst.html) another wiki markup format similar to Markdown.\n",
336+
"Sphinx uses [RestructuredText](https://docutils.sourceforge.io/rst.html) another wiki markup format similar to Markdown.\n",
300337
"\n",
301338
"You define an \"index.rst\" file to contain any preamble text you want. The rest is autogenerated by `sphinx-quickstart`\n",
302339
"\n",
@@ -363,7 +400,7 @@
363400
"name": "stdout",
364401
"output_type": "stream",
365402
"text": [
366-
"Running Sphinx v1.8.0\n"
403+
"Running Sphinx v4.2.0\n"
367404
]
368405
},
369406
{
@@ -389,7 +426,7 @@
389426
"cell_type": "markdown",
390427
"metadata": {},
391428
"source": [
392-
"Sphinx's output is [html](http://github-pages.ucl.ac.uk/rsd-engineeringcourse/ch04packaging/greetings/doc/index.html). We just created a simple single function's documentation, but Sphinx will create\n",
429+
"Sphinx's output is [html](./greetings/doc/index.html). We just created a simple single function's documentation, but Sphinx will create\n",
393430
"multiple nested pages of documentation automatically for many functions.\n",
394431
"\n",
395432
"\n",
@@ -409,7 +446,7 @@
409446
"source": [
410447
"`doctest` is a module included in the standard library. It runs all the code within the docstrings and checks whether the output is what it's claimed on the documentation.\n",
411448
"\n",
412-
"Let's add an example to our greeting function and check it with `doctest`. We are leaving the output with a small typo to see what's the type of output we get from `doctest`."
449+
"Let's add an example to our greeting function and check it with `doctest`. We are leaving the output with a small typo (missing the closing quote `'`) to see what's the type of output we get from `doctest`."
413450
]
414451
},
415452
{

0 commit comments

Comments
 (0)