5.6. Updating documentation

Once you have created the documentation, there are a number of ways to allow others to update it.

Note

As part of best practice guidelines, it is recommended to use a version control system for tracking commits to your code and host your code on a online version control service such as github. The following assumes you are following these best practice guidelines.

Important

See the best practices guide for more information on the how to contribute software projects.

Updating documentation online

You can directly edit existing documentation online, for example on github. This approach allows you to contribute changes using only a web browser.

  1. Navigate to the repository of interest.

  2. If the repository does not belong to you, fork the repository, (part of the best practice guidelines). You can do this by clicking on the fork icon on the top right of the repository. This will create a copy of the repository on your github account.

  3. In the project, select the file that you wish to edit (e.g. a file ending with .md (Markdown) or .rst (reST)). The rendered preview of the file will appear.

  4. Click on the pencil button as shown in the screenshot below to edit the file.

../../_images/editing_docs_on_github.png

Editing documentation on github.

This will open the editor mode showing the file in markup format.

../../_images/edit_mode_on_github.png

Editing mode on github.

  1. Make edits.

  2. Preview edits by clicking on the Preview tab.

../../_images/previewing_doc_edits_on_github.png

Previewing changes on github.

  1. Once you are finished, scroll to the bottom of the page to the Section named Commit changes.

  1. Add a title to your commit that summarises the change that you made.

  2. Add an optional extended description.

../../_images/committing_changes_on_github.png

Committing changes on github.

  1. Decide whether you want to commit directly to the master branch or make the commit to a new branch and start a pull request (best practice guidelines recommend the latter option.

  2. Create a pull request from your fork to the main repository. This will allow the owner of the main repository to review your changes and determine whether it can be contributed back into the main repository.

Important

See the best practices guide for more information on the how to contribute software projects.

For additional information see the following outline on contributing to documentation via github.

Updating documentation locally using an IDE

Alternatively, you can create a local copy of the project on your computer (forking and cloning the code). You can then edit the source code as desired using your IDE of choice (e.g. PyCharm). You can then follow the best practice guidelines to commit and contribute your code into the project’s main repository through a pull request.

Updating documentation with PyCharm

This section describes how to add a sphinx build configuration to PyCharm:

  1. Open Pycharm.

  2. FileOpen → Navigate to your project folder -> Click Ok.

  3. RunEdit configurations.

  4. Click the + → button on the top left of the window to add a new configuration.

../../_images/pycharm_edit_configurations.png

Add new run configuration in PhyCharm.

  1. Select python docssphinx task

../../_images/pycharm_add_sphinx_task.png

Add new run configuration in PhyCharm.

  1. Complete the following fields in the configuration task:

  1. Name: Sphinx task

  2. Input: Select the source directory in the documentation folder (typically, the docs/source folder).

  3. Output: Select the build directory in the documentation folder (typically, the docs/build folder, if this does not exist copy paste the path you have specified for the Input above, and replace source with build).

  4. Python interpreter: Select your python interpreter.

  5. Options: -E -a (This options forces rebuild of html).

../../_images/pycharm_final_sphinx_configuration.png

Example of a Sphinx task in PhyCharm.

  1. Click Ok.

  2. You can now run the configuration by pressing the green play button.

  3. Once you have finished editing the documentation you can commit your changes to your fork of the repository e.g. using Gitkraken, and create a pull request to notify the developers of the main repository that you have changes ready to be pulled into the main repository.

See also

Note that Python provides a markdown plugin that allows for dynamic previewing of markdown files as shown in the figure below:

../../_images/pycharm_dynamic_markdown_preview.png

PyCharm Markdown preview plugin.

Warning

On occasion, a bug in the extension results very high CPU usage, slowing down the performance of PyCharm. To address this issue, you need to close any open Markdown files and restart PyCharm. Alternatively, you can disable the Markdown plugin.