|
| 1 | +Contributors Guide |
| 2 | +------------------ |
| 3 | + |
| 4 | +This is a community driven project and everyone is welcome to contribute. The |
| 5 | +project is hosted at the `gmt-examples GitHub repository <https://github.com/GenericMappingTools/gmt-examples>`_. |
| 6 | + |
| 7 | +The goal is to maintain a diverse community that's pleasant for everyone. |
| 8 | +**Please be considerate and respectful of others**. Everyone must abide by our |
| 9 | +`Code of Conduct <https://github.com/GenericMappingTools/gmt-examples/blob/main/CODE_OF_CONDUCT.md>`_ |
| 10 | +and we encourage all to read it carefully. |
| 11 | + |
| 12 | +GMT Examples Overview |
| 13 | +~~~~~~~~~~~~~~~~~~~~~ |
| 14 | + |
| 15 | +There are two main components to GMT examples project: |
| 16 | + |
| 17 | +* Gallery examples, with source material in the ``docs/gallery/`` folder. |
| 18 | +* Tutorial examples, with source material in the ``docs/tutorials/`` folder. |
| 19 | + |
| 20 | +The gallery examples are designed to instruct users on how to complete a specific |
| 21 | +problem. For general recommendations on how to design effective gallery examples, |
| 22 | +see the `diataxis framework's section on how-to guides <https://diataxis.fr/how-to-guides/>`_. |
| 23 | + |
| 24 | +The tutorials are learning orientated with the goal of teaching users GMT. For |
| 25 | +general recommendations on how to design effective tutorials, see the |
| 26 | +`diataxis framework's section on tutorials <https://diataxis.fr/tutorials/>`_. |
| 27 | + |
| 28 | +The documentation are written primarily in |
| 29 | +`reStructuredText <https://docutils.sourceforge.io/rst.html>`_ and built by |
| 30 | +`Sphinx <http://www.sphinx-doc.org/>`_. Please refer to |
| 31 | +:gmt-module:`reStructuredText cheatsheet <devdocs/rst-cheatsheet.html>` if you are new to reStructuredText. |
| 32 | + |
| 33 | +Setting up your environment |
| 34 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 35 | + |
| 36 | +The following dependencies are required for building the GMT examples pages: |
| 37 | + |
| 38 | +- `gmt <https://docs.generic-mapping-tools.org/latest/>`_ (GMT is required for executing example scripts) |
| 39 | +- `sphinx <http://www.sphinx-doc.org/>`_ (a Python documentation generator for creating the docs from source files) |
| 40 | +- `sphinx_gmt <https://www.generic-mapping-tools.org/sphinx_gmt/latest/>`_ (a Sphinx extension for creating GMT figures to accompany example scripts) |
| 41 | +- `sphinx_rtd_theme <https://sphinx-rtd-theme.readthedocs.io/en/stable/>`_ (a Sphinx theme used for consistent documentation appearance between GMT projects) |
| 42 | + |
| 43 | +Two options for installing the dependencies are :ref:`pip <Pip Setup>` and :ref:`conda <Conda Setup>`. |
| 44 | +Since Sphinx is a Python documentation generator, you will need a working Python |
| 45 | +environment. For those who do not already have a working Python environment, |
| 46 | +one option is to use the minimal installer for Conda `Miniforge <https://github.com/conda-forge/miniforge>`_ |
| 47 | +along with the :ref:`conda <Conda Setup>` instructions. |
| 48 | + |
| 49 | +Pip Setup |
| 50 | +^^^^^^^^^ |
| 51 | + |
| 52 | +These instructions rely on the `pip <https://pip.pypa.io/en/stable/>`_ package |
| 53 | +installer, which can be used to install all dependencies except GMT. |
| 54 | +Follow the `GMT Install Guide <https://github.com/GenericMappingTools/gmt/blob/master/INSTALL.md>`_ |
| 55 | +to install GMT. The Python dependencies can be installed using the |
| 56 | +``requirements.txt`` from the base of the repository (you may wish to setup a |
| 57 | +`virtual environment <https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#creating-a-virtual-environment>`_ first): |
| 58 | + |
| 59 | +Unix/macOS:: |
| 60 | + |
| 61 | + python -m pip install -r requirements.txt |
| 62 | + |
| 63 | +Windows:: |
| 64 | + |
| 65 | + py -m pip install -r requirements.txt |
| 66 | + |
| 67 | +Conda Setup |
| 68 | +^^^^^^^^^^^ |
| 69 | + |
| 70 | +These instructions rely on the `conda <https://docs.conda.io/en/latest/>`_ package |
| 71 | +manager. Run the following from the base of the repository to create a new conda |
| 72 | +environment from the ``environment.yml`` file:: |
| 73 | + |
| 74 | + conda env create |
| 75 | + |
| 76 | +Before building the documentation, you have to activate the environment |
| 77 | +(you'll need to do this every time you start a new terminal):: |
| 78 | + |
| 79 | + conda activate gmt-examples |
| 80 | + |
| 81 | +Building the documentation |
| 82 | +~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 83 | + |
| 84 | +Once you have :ref:`setup your environment <Setting up your environment>`, you can |
| 85 | +build the documentation using:: |
| 86 | + |
| 87 | + cd docs |
| 88 | + make html |
| 89 | + |
| 90 | +Contributing New Examples |
| 91 | +~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 92 | + |
| 93 | +The source files for the gallery examples and tutorials are ``.rst`` files in |
| 94 | +``docs/`` that generate one or more figures using the |
| 95 | +`sphinx_gmt <https://www.generic-mapping-tools.org/sphinx_gmt/latest/)>`_ |
| 96 | +extension. To add a new gallery example or tutorial: |
| 97 | + |
| 98 | +* If necessary, create a new sub-directory under ``docs/gallery/`` for a |
| 99 | + gallery example section (e.g., ``basemaps/`` or ``plot_embellishments/``). |
| 100 | +* Create a new ``.rst`` file inside the appropriate sub-directory in |
| 101 | + ``docs/gallery/`` or ``docs/tutorials/``. |
| 102 | +* Add a descriptive title and as much explanation as necessary. |
| 103 | +* Add hyperlinks to GMT modules using the ``gmt-module`` reStructuredText directive:: |
| 104 | + |
| 105 | + :gmt-module:`grdview` |
| 106 | + |
| 107 | +* Add hyperlinks to GMT module options by appending lower-case ``#<option>`` to |
| 108 | + the ``gmt-module`` argument:: |
| 109 | + |
| 110 | + :gmt-module:`grdview#q` |
| 111 | + |
| 112 | +* Add as many figures as needed using the ``gmtplot`` directive: |
| 113 | + |
| 114 | + :: |
| 115 | + |
| 116 | + .. gmtplot:: |
| 117 | + |
| 118 | + gmt begin basemap png |
| 119 | + gmt basemap -B -Rg -JH5c |
| 120 | + gmt end show |
| 121 | + |
| 122 | + The figures will be placed after the source code in the built documentation |
| 123 | + by the ``sphinx_gmt`` extension. |
| 124 | + |
| 125 | +* Add the file to the appropriate section in ``docs/index.rst`` using the following |
| 126 | + template: |
| 127 | + |
| 128 | + :: |
| 129 | + |
| 130 | + ```bash |
| 131 | + - .. image:: _images/<file-name>-gmtplot-0.png |
| 132 | + :target: gallery/<section>/<file-name>.html |
| 133 | + :width: 80% |
| 134 | + :align: center |
| 135 | + |
| 136 | + :doc:`gallery/<section>/<file-name>` |
| 137 | + ``` |
| 138 | + |
| 139 | + Edit the number in the ``.. image:: ...`` line to show a different figure on the |
| 140 | + index page. |
0 commit comments