github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/docs/source/docs_guide.md (about)

     1  # Contributing documentation
     2  
     3  **Audience**: Anyone who would like to contribute to the Fabric documentation.
     4  
     5  This short guide describes how the Fabric documentation is structured, built and
     6  published, as well as a few conventions that help writers make changes to the
     7  Fabric documentation.
     8  
     9  In this topic, we're going to cover:
    10  * [An introduction to the documentation](#introduction)
    11  * [Repository folder structure](#repository-folders)
    12  * [International language folder structure](#international-folders)
    13  * [Making documentation changes](#making-changes)
    14  * [Building the documentation on your local machine](#building-locally)
    15  * [Building the documentation on GitHub with ReadTheDocs](#building-on-github)
    16  * [Getting your change approved](#making-a-pr)
    17  * [Making a change to Commands Reference](#commands-reference-updates)
    18  * [Adding a new CLI command](#adding-a-new-cli-command)
    19  
    20  ## Introduction
    21  
    22  The Fabric documentation is written in a combination of
    23  [Markdown](https://www.markdownguide.org/) and
    24  [reStructuredText](http://docutils.sourceforge.net/rst.html) source files. As a
    25  new author you can use either format. We recommend that you use Markdown as an
    26  easy and powerful way to get started. If you have a background in Python, you
    27  may prefer to use rST.
    28  
    29  During the documentation build process, the documentation source files are
    30  converted to HTML using [Sphinx](http://www.sphinx-doc.org/en/stable/). The
    31  generated HTML files are subsequently published on the [public documentation
    32  website](http://hyperledger-fabric.readthedocs.io). Users can select both
    33  different languages and different versions of the Fabric documentation.
    34  
    35  For example:
    36  
    37    * [Latest version of US English](https://hyperledger-fabric.readthedocs.io/en/{BRANCH_DOC}/)
    38    * [Latest version of Chinese](https://hyperledger-fabric.readthedocs.io/zh_CN/{BRANCH_DOC}/)
    39    * [Version 2.2 of US English](https://hyperledger-fabric.readthedocs.io/en/release-2.2/)
    40    * [Version 1.4 of US English](https://hyperledger-fabric.readthedocs.io/en/release-1.4/)
    41  
    42  For historical reasons, the US English source files live in the main [Fabric
    43  repository](https://github.com/hechain20/hechain/), whereas all international
    44  language source files live in a single [Fabric i18n
    45  repository](https://github.com/hyperledger/fabric-docs-i18n). Different versions
    46  of the documentation are held within the appropriate GitHub release branch.
    47  
    48  ## Repository folders
    49  
    50  Both the US English and international language repositories have essentially the
    51  same structure, so let's start by examining the US English source files.
    52  
    53  All files relating to documentation reside within the `fabric/docs/` folder:
    54  
    55  ```bash
    56  fabric/docs
    57  ├── custom_theme
    58  ├── source
    59  │   ├── _static
    60  │   ├── _templates
    61  │   ├── commands
    62  │   ├── create_channel
    63  │   ├── dev-setup
    64  │   ├── developapps
    65  │   ├── diagrams
    66  │   ...
    67  │   ├── orderer
    68  │   ├── peers
    69  │   ├── policies
    70  │   ├── private-data
    71  │   ├── smartcontract
    72  │   ├── style-guides
    73  │   └── tutorial
    74  └── wrappers
    75  ```
    76  
    77  The most important folders is `source/` because it holds the source language
    78  files. The documentation build process uses the `make` command to convert these
    79  source files to HTML, which are stored in the dynamically created `build/html/`
    80  folder:
    81  
    82  ```bash
    83  fabric/docs
    84  ├── build
    85  │   ├── html
    86  ├── custom_theme
    87  ├── source
    88  │   ├── _static
    89  │   ├── _templates
    90  │   ├── commands
    91  │   ├── create_channel
    92  │   ├── dev-setup
    93  │   ├── developapps
    94  │   ├── diagrams
    95      ...
    96  ```
    97  
    98  Spend a little time navigating the [docs
    99  folder](https://github.com/hechain20/hechain/tree/main/docs) in the
   100  Hechain repository. Click on the following links to see how different
   101  source files map to their corresponding published topics.
   102  
   103  * [`/docs/source/index.rst`](https://raw.githubusercontent.com/hyperledger/fabric/main/docs/source/index.rst) maps to [Hechain title page](https://hyperledger-fabric.readthedocs.io/en/{RTD_TAG}/)
   104  
   105  * [`/docs/source/developapps/developing-applications.rst`](https://raw.githubusercontent.com/hyperledger/fabric/main/docs/source/developapps/developing_applications.rst)
   106    maps to [Developing
   107    applications](https://hyperledger-fabric.readthedocs.io/en/{RTD_TAG}/developapps/developing_applications.html)
   108  
   109  * [`/docs/source/peers/peers.md`](https://raw.githubusercontent.com/hyperledger/fabric/main/docs/source/peers/peers.md)
   110    maps to
   111    [Peers](https://hyperledger-fabric.readthedocs.io/en/{RTD_TAG}/peers/peers.html)
   112  
   113  We'll see how to make changes to these files a little later.
   114  
   115  ## International folders
   116  The international language repository,
   117  [`fabric-docs-i18n`](https://github.com/hyperledger/fabric-docs-i18n), follows
   118  almost exactly the same structure as the
   119  [`fabric`](https://github.com/hyperledger/fabric) repository which holds the US
   120  English files.  The difference is that each language is located within its own
   121  folder within `docs/locale/`:
   122  
   123  ```bash
   124  fabric-docs-i18n/docs
   125  └── locale
   126      ├── ja_JP
   127      ├── ml_IN
   128      ├── pt_BR
   129      └── zh_CN
   130  ```
   131  Examining any one of these folders shows a familiar structure:
   132  ```bash
   133  locale/ml_IN
   134  ├── custom_theme
   135  ├── source
   136  │   ├── _static
   137  │   ├── _templates
   138  │   ├── commands
   139  │   ├── dev-setup
   140  │   ├── developapps
   141  │   ├── diagrams
   142  │   ...
   143  │   ├── orderer
   144  │   ├── peers
   145  │   ├── policies
   146  │   ├── private-data
   147  │   ├── smartcontract
   148  │   ├── style-guides
   149  │   └── tutorial
   150  └── wrappers
   151  ```
   152  
   153  As we'll soon see, the similarity of the international language and US English
   154  folder structures means that the same instructions and commands can be used to
   155  manage different language translations.
   156  
   157  Again, spend some time examining the [international language
   158  repository](https://github.com/hyperledger/fabric-docs-i18n).
   159  
   160  ## Making changes
   161  
   162  To update the documentation, you simply change one or more language source files
   163  in a local git feature branch, build the changes locally to check they're OK,
   164  and submit a Pull request (PR) to merge your branch with the appropriate Fabric
   165  repository branch. Once your PR has been reviewed and approved by the appropriate
   166  maintainers for the language, it will be merged into the repository and become
   167  part of the published documentation. It really is that easy!
   168  
   169  As well as being polite, it's a really good idea to test any documentation
   170  changes before you request to include it in a repository. The following sections
   171  show you how to:
   172  
   173  * Build and review a documentation change on your own machine.
   174  
   175  
   176  * Push these changes to your GitHub repository fork where they can populate your
   177    personal [ReadTheDocs](https://readthedocs.org/) publication website for
   178    collaborators to review.
   179  
   180  
   181  * Submit your documentation PR for inclusion in the `fabric` or
   182    `fabric-docs-i18n` repository.
   183  
   184  ## Building locally
   185  
   186  Use these simple steps to build the documentation.
   187  
   188  1. Create a fork of the appropriate
   189  [`fabric`](https://github.com/hyperledger/fabric) or
   190  [`fabric-i18n`](https://github.com/hyperledger/fabric-docs-i18n) repository to
   191  your GitHub account.
   192  
   193  2. Install the following prerequisites; you may need to adjust depending on your
   194     OS:
   195  
   196     * [Docker](https://docs.docker.com/get-docker/)
   197  
   198  3. For US English:
   199     ```bash
   200     git clone git@github.com:hyperledger/fabric.git
   201     cd fabric
   202     make docs
   203     ```
   204  
   205     For International Languages (Malayalam as an example):
   206     ```bash
   207     git clone git@github.com:hyperledger/fabric-docs-i18n.git
   208     cd fabric-docs-i18n
   209     make docs-lang-ml_IN
   210     ```
   211  
   212     The `make` command generates documentation html files in the `docs/build/html/`
   213     folder which you can now view locally; simply navigate your browser to the
   214     `docs/build/html/index.html` file. For International Languages, you need to read `docs/build/html/` as
   215     `docs/locale/${LANG_CODE}/_build/html/` (e.g., `docs/locale/ml_IN/_build/html/`).
   216  
   217  4. Now make a small change to a file, and rebuild the documentation to verify
   218     that your change was as expected. Every time you make a change to the
   219     documentation you will of course need to rerun `make docs`.
   220  
   221  5. If you'd like, you may also run a local web server with the following
   222     commands (or equivalent depending on your OS):
   223  
   224     ```bash
   225     sudo apt-get install apache2
   226     cd docs/build/html
   227     sudo cp -r * /var/www/html/
   228     ```
   229  
   230     You can then access the html files at `http://localhost/index.html`.
   231  
   232  6. You can learn how to make a PR [here](./github/github.html). Moreover, if you
   233     are new to git or GitHub, you will find the [Git
   234     book](https://git-scm.com/book/en/v2) invaluable.
   235  
   236  ## Building on GitHub
   237  
   238  It is often helpful to use your fork of the Fabric repository to build the
   239  Fabric documentation so that others can review your changes before you submit
   240  them for approval. The following instructions show you how to use ReadTheDocs to
   241  do this.
   242  
   243  1. Go to [`http://readthedocs.org`](http://readthedocs.org) and sign up for an
   244     account. Choose the "sign up with GitHub" option.
   245  2. Fork the [`fabric`](https://github.com/hyperledger/fabric) repository.
   246  3. Import a project. Select your fork of the fabric repository. You will need to
   247     create a unique name for the project, such as YOUR_USERNAME-fabric.
   248  4. Check in the `Admin`, `Integrations` settings to verify you have one `GitHub
   249     incoming webhook`.
   250  5. From your fork, go to `Settings` in the upper right portion of the screen.
   251  6. Click `Webhooks`.
   252  7. Find your new webhook. It will begin with
   253    `https://readthedocs.org/api/v2/webhook/YOUR_PROJECT_NAME`
   254  8. Scroll to the `Which events would you like to trigger this webhook?` setting
   255     and unselect `Pull requests`.
   256  9. Click `Update webhook`.
   257  
   258  Use `fabric-docs-i18n` instead of `fabric` in the above instructions if you're
   259  building an international language translation.
   260  
   261  Now, anytime you modify or add documentation content to your fork, this URL will
   262  automatically get updated with your changes!
   263  
   264  ## Making a PR
   265  
   266  You can submit your PR for inclusion using the following
   267  [instructions](./github/github.html).
   268  
   269  Pay special attention to signing your commit with the `-s` option:
   270  
   271  ```bash
   272  git commit -s -m "My Doc change"
   273  ```
   274  
   275  This states that your changes conform to the [Developer Certificate of
   276  Origin](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin).
   277  
   278  Before your PR can be included in the appropriate `fabric` or `fabric-docs-i18n`
   279  repository, it must be approved by an appropriate maintainer. For example, a
   280  Japanese translation must be approved by a Japanese maintainer, and so on. You
   281  can find the maintainers listed in the following `CODEOWNERS` files:
   282  
   283  * US English
   284    [`CODEOWNERS`](https://github.com/hechain20/hechain/blob/main/CODEOWNERS)
   285    and their [maintainer GitHub
   286    IDs](https://github.com/orgs/hyperledger/teams/fabric-core-doc-maintainers)
   287  * International language
   288    [`CODEOWNERS`](https://github.com/hyperledger/fabric-docs-i18n/blob/main/CODEOWNERS)
   289    and their [maintainer GitHub
   290    IDs](https://github.com/orgs/hyperledger/teams/fabric-contributors)
   291  
   292  Both language repositories have a GitHub webhook defined so that, once approved,
   293  your newly merged content in the `docs/` folder will trigger an automatic build
   294  and publication of the updated documentation.  
   295  
   296  **Note:** Documentation maintainers are not able to to merge documentation PRs by clicking the `Merge pull request` button. Instead, if you are a documentation maintainer and have approved the PR, simply add the label `doc-merge` to the PR and a `Mergify` bot that runs every minute will merge the PR.
   297  
   298  
   299  ## Commands Reference updates
   300  
   301  Updating content in the [Commands
   302  Reference](https://hyperledger-fabric.readthedocs.io/en/{BRANCH_DOC}/command_ref.html)
   303  topic requires additional steps. Because the information in the Commands
   304  Reference topic is generated content, you cannot simply update the associated
   305  markdown files.
   306  - Instead you need to update the `_preamble.md` or `_postscript.md` files under
   307    `src/github.com/hechain20/hechain/docs/wrappers` for the command.
   308  - To update the command help text, you need to edit the associated `.go` file
   309    for the command that is located under `/fabric/internal/peer`.
   310  - Then, from the `fabric` folder, you need to run the command `make help-docs`
   311    which generates the updated markdown files under `docs/source/commands`.
   312  
   313  Remember that when you push the changes to GitHub, you need to include the
   314  `_preamble.md`, `_postscript.md` or `_.go` file that was modified as well as the
   315  generated markdown file.
   316  
   317  This process only applies to English language translations. Command Reference
   318  translation is currently not possible in international languages.
   319  
   320  ## Adding a new CLI command
   321  
   322  To add a new CLI command, perform the following steps:
   323  
   324  - Create a new folder under `/fabric/internal/peer` for the new command and the
   325    associated help text. See `internal/peer/version` for a simple example to get
   326    started.
   327  - Add a section for your CLI command in
   328    `src/github.com/hechain20/hechain/scripts/generateHelpDoc.sh`.
   329  - Create two new files under `/src/github.com/hechain20/hechain/docs/wrappers`
   330    with the associated content:
   331    - `<command>_preamble.md` (Command name and syntax)
   332    - `<command>_postscript.md` (Example usage)
   333  - Run `make help-docs` to generate the markdown content and push all of the
   334    changed files to GitHub.
   335  
   336  This process only applies to English language translations. CLI
   337  command translation is currently not possible in international languages.
   338  
   339  <!--- Licensed under Creative Commons Attribution 4.0 International License
   340  https://creativecommons.org/licenses/by/4.0/ -->