|
| 1 | +# Where to find the docs |
| 2 | + |
| 3 | +The GPJax documentation can be found here: |
| 4 | +https://gpjax.readthedocs.io/en/latest/ |
| 5 | + |
| 6 | +# How to build the docs |
| 7 | + |
| 8 | +1. Install the requirements using `pip install -r docs/requirements.txt` |
| 9 | +2. Make sure `pandoc` is installed |
| 10 | +3. Run the make script `make html` |
| 11 | + |
| 12 | +The corresponding HTML files can then be found in `docs/_build/html/`. |
| 13 | + |
| 14 | +# How to write code documentation |
| 15 | + |
| 16 | +Our documentation it is written in ReStructuredText for Sphinx. This is a |
| 17 | +meta-language that is compiled into online documentation. For more details see |
| 18 | +[Sphinx's documentation](https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html). |
| 19 | +As a result, our docstrings adhere to a specific syntax that has to be kept in |
| 20 | +mind. Below we provide some guidelines. |
| 21 | + |
| 22 | +## How much information to put in a docstring |
| 23 | + |
| 24 | +A docstring should be informative. If in doubt, then it is best to add more |
| 25 | +information to a docstring than less. Many users will skim documentation, so |
| 26 | +please ensure the opening sentence or two of a docstring contains the core |
| 27 | +information. Adding examples and mathematical descriptions to documentation is |
| 28 | +highly desirable. |
| 29 | + |
| 30 | +We are making an active effort within GPJax to improve our documentation. If you |
| 31 | +spot any areas where there is missing information within the existing |
| 32 | +documentation, then please either raise an issue or |
| 33 | +[create a pull request](https://gpjax.readthedocs.io/en/latest/contributing.html). |
| 34 | + |
| 35 | +## An example docstring |
| 36 | + |
| 37 | +An example docstring that adheres the principles of GPJax is given below. |
| 38 | +The docstring contains a simple, snappy introduction with links to auxillary |
| 39 | +components. More detail is then provided in the form of a mathematical |
| 40 | +description and a code example. The docstring is concluded with a description |
| 41 | +of the objects attributes with corresponding types. |
| 42 | + |
| 43 | +```python |
| 44 | +class Prior(AbstractPrior): |
| 45 | + """A Gaussian process prior object. The GP is parameterised by a |
| 46 | + `mean <https://gpjax.readthedocs.io/en/latest/api.html#module-gpjax.mean_functions>`_ |
| 47 | + and `kernel <https://gpjax.readthedocs.io/en/latest/api.html#module-gpjax.kernels>`_ function. |
| 48 | + |
| 49 | + A Gaussian process prior parameterised by a mean function :math:`m(\\cdot)` and a kernel |
| 50 | + function :math:`k(\\cdot, \\cdot)` is given by |
| 51 | + |
| 52 | + .. math:: |
| 53 | + |
| 54 | + p(f(\\cdot)) = \mathcal{GP}(m(\\cdot), k(\\cdot, \\cdot)). |
| 55 | + |
| 56 | + To invoke a ``Prior`` distribution, only a kernel function is required. By default, |
| 57 | + the mean function will be set to zero. In general, this assumption will be reasonable |
| 58 | + assuming the data being modelled has been centred. |
| 59 | + |
| 60 | + Example: |
| 61 | + >>> import gpjax as gpx |
| 62 | + >>> |
| 63 | + >>> kernel = gpx.kernels.RBF() |
| 64 | + >>> prior = gpx.Prior(kernel = kernel) |
| 65 | + |
| 66 | + Attributes: |
| 67 | + kernel (Kernel): The kernel function used to parameterise the prior. |
| 68 | + mean_function (MeanFunction): The mean function used to parameterise the prior. Defaults to zero. |
| 69 | + name (str): The name of the GP prior. Defaults to "GP prior". |
| 70 | + """ |
| 71 | + |
| 72 | + kernel: Kernel |
| 73 | + mean_function: Optional[AbstractMeanFunction] = Zero() |
| 74 | + name: Optional[str] = "GP prior" |
| 75 | +``` |
| 76 | + |
| 77 | +### Documentation syntax |
| 78 | + |
| 79 | +A helpful cheatsheet for writing restructured text can be found |
| 80 | +[here](https://github.com/ralsina/rst-cheatsheet/blob/master/rst-cheatsheet.rst). In addition to that, we adopt the following convention when documenting |
| 81 | +`` objects. |
| 82 | + |
| 83 | +* Class attributes should be specified using the `Attributes:` tag. |
| 84 | +* Method argument should be specified using the `Args:` tags. |
| 85 | +* All attributes and arguments should have types. |
0 commit comments