|
| 1 | +# Documentation README |
| 2 | + |
| 3 | +## Introduction |
| 4 | + |
| 5 | +This document contains information on how the Fabric documentation is |
| 6 | +built and published as well as a few conventions one should be aware of |
| 7 | +before making changes to the doc. |
| 8 | + |
| 9 | +The crux of the documentation is written in |
| 10 | +[reStructuredText](http://docutils.sourceforge.net/rst.html) which is |
| 11 | +converted to HTML using [Sphinx](http://www.sphinx-doc.org/en/stable/). |
| 12 | +The HTML is then published on http://hyperledger-fabric.readthedocs.io |
| 13 | +which has a hook so that any new content that goes into `docs/source` |
| 14 | +on the main repository will trigger a new build and publication of the |
| 15 | +doc. |
| 16 | + |
| 17 | +## Conventions |
| 18 | + |
| 19 | +* Source files are in RST format and found in the `docs/source` directory. |
| 20 | +* The main entry point is index.rst, so to add something into the Table |
| 21 | + of Contents you would simply modify that file in the same manner as |
| 22 | + all of the other topics. It's very self-explanatory once you look at |
| 23 | + it. |
| 24 | +* Relative links should be used whenever possible. The preferred |
| 25 | + syntax for this is: :doc:\`anchor text <relativepath>\` |
| 26 | + <br/>Do not put the .rst suffix at the end of the filepath. |
| 27 | +* For non RST files, such as text files, MD or YAML files, link to the |
| 28 | + file on github, like this one for instance: |
| 29 | + https://github.com/hyperledger/fabric/blob/master/docs/README.md |
| 30 | + |
| 31 | +Notes: The above means we have a dependency on the github mirror |
| 32 | +repository. Relative links are unfortunately not working on github |
| 33 | +when browsing through a RST file. |
| 34 | + |
| 35 | +## Setup |
| 36 | + |
| 37 | +Making any changes to the documentation will require you to test your |
| 38 | +changes by building the doc in a way similar to how it is done for |
| 39 | +production. There are two possible setups you can use to do so: |
| 40 | +setting up your own staging repo and publication website, or building |
| 41 | +the docs on your machine. The following sections cover both options: |
| 42 | + |
| 43 | +### Setting up your own staging repo and publication website |
| 44 | + |
| 45 | +You can easily build your own staging repo following these steps: |
| 46 | + |
| 47 | +1. Fork [fabric on github](https://github.com/hyperledger/fabric) |
| 48 | +1. From your fork, go to `settings` in the upper right portion of the screen, |
| 49 | +1. click `Integration & services`, |
| 50 | +1. click `Add service` dropdown, |
| 51 | +1. and scroll down to ReadTheDocs. |
| 52 | +1. Next, go to http://readthedocs.org and sign up for an account. One of the first prompts will offer to link to github. Elect this then, |
| 53 | +1. click import a project, |
| 54 | +1. navigate through the options to your fork (e.g. yourgithubid/fabric), |
| 55 | +1. it will ask for a name for this project. Choose something |
| 56 | +intuitive. Your name will preface the URL and you may want to append `-fabric` to ensure that you can distinguish between this and other docs that you need to create for other projects. So for example: |
| 57 | +`yourgithubid-fabric.readthedocs.io/en/latest` |
| 58 | + |
| 59 | +Now anytime you modify or add documentation content to your fork, this |
| 60 | +URL will automatically get updated with your changes! |
| 61 | + |
| 62 | +### Building the docs on your machine |
| 63 | + |
| 64 | +Here are the quick steps to achieve this on a local machine without |
| 65 | +depending on ReadTheDocs, starting from the main fabric |
| 66 | +directory. Note: you may need to adjust depending on your OS. |
| 67 | + |
| 68 | +``` |
| 69 | +sudo pip install Sphinx |
| 70 | +sudo pip install sphinx_rtd_theme |
| 71 | +cd fabric/docs # Be in this directory. Makefile sits there. |
| 72 | +make html |
| 73 | +``` |
| 74 | + |
| 75 | +This will generate all the html files in `docs/build/html` which you can |
| 76 | +then start browsing locally using your browser. Every time you make a |
| 77 | +change to the documentation you will of course need to rerun `make |
| 78 | +html`. |
| 79 | + |
| 80 | +In addition, if you'd like, you may also run a local web server with the following commands (or equivalent depending on your OS): |
| 81 | + |
| 82 | +``` |
| 83 | +sudo apt-get install apache2 |
| 84 | +cd source/build/html |
| 85 | +sudo cp -r * /var/www/html/ |
| 86 | +``` |
| 87 | + |
| 88 | +You can then access the html files at `http://localhost/index.html`. |
0 commit comments