|
6 | 6 |
|
7 | 7 | InvenioRDM user documentation web site.
|
8 | 8 |
|
9 |
| -## Running |
| 9 | +## Run the docs locally |
10 | 10 |
|
11 | 11 | ```console
|
12 | 12 | $ mkvirtualenv docs-invenio-rdm
|
13 | 13 | $ pip install -r requirements.txt
|
14 |
| -$ mkdocs serve |
| 14 | +$ mkdocs serve # mike serve if you are using mike for versioning |
15 | 15 | $ firefox http://127.0.0.1:8000
|
16 | 16 | ```
|
| 17 | + |
| 18 | +## Set up versioning |
| 19 | + |
| 20 | +This means having `/x.y.z/` at the end of the url to point to a specific release |
| 21 | +version. You can also set up aliases to have `latest` or any desire string tag. |
| 22 | + |
| 23 | +### Initial setup, onte time operations |
| 24 | + |
| 25 | +#### Create the documentation branch |
| 26 | + |
| 27 | +Create and orphan branch called `gh-pages`. This name is mandatory to avoid |
| 28 | +extra configuration in mike and GitHub. |
| 29 | + |
| 30 | +``` console |
| 31 | +$ git checkout master |
| 32 | +$ git checkout --orphan gh-pages |
| 33 | +$ rm -rf ./* |
| 34 | +$ git rm -r ./* |
| 35 | +$ git commit -m "initial commit: index redirect" |
| 36 | +$ git push origin gh-pages |
| 37 | +``` |
| 38 | + |
| 39 | +Why an orphan branch? In order to separate the build documentation from the |
| 40 | +source of it. |
| 41 | + |
| 42 | +#### Create a latest redirection |
| 43 | + |
| 44 | +By default GitHub pages serve the `index.html` file from the root directory. |
| 45 | +Mike does not build one by default, and we would like the documentation site |
| 46 | +to point to `/latest`. We can use the `set-default` command: |
| 47 | + |
| 48 | +``` console |
| 49 | +$ mike set-default latest -p |
| 50 | +``` |
| 51 | + |
| 52 | +#### Install [mike](https://github.com/jimporter/mike) |
| 53 | + |
| 54 | +Create a new branch (to do a PR from) and install mike's extras: |
| 55 | + |
| 56 | +``` console |
| 57 | +$ git checkout master |
| 58 | +$ git checkout -b versioning |
| 59 | +$ mike install-extras |
| 60 | +``` |
| 61 | + |
| 62 | +Add and commit the changes. This will include formating of the `mkdocs.yaml` |
| 63 | +plus some additions. As well as the css and js files needed for mike. |
| 64 | + |
| 65 | +``` console |
| 66 | +$ git add -p |
| 67 | +$ git add docs/css/ |
| 68 | +$ git add docs/js/ |
| 69 | +$ git commit -m "versioning: add mikes extras" |
| 70 | +$ git push origin versioning |
| 71 | +``` |
| 72 | + |
| 73 | +**Note**: You might want to add `mike` to the requiresments.txt although it is |
| 74 | +not necesary for the build itself. |
| 75 | + |
| 76 | +### Operations |
| 77 | + |
| 78 | +#### Deploy! |
| 79 | + |
| 80 | +First of all fetch all branches to help mike sync. It does a great job on |
| 81 | +this, but is better to be sure. |
| 82 | + |
| 83 | +``` console |
| 84 | +$ git fetch --all |
| 85 | +``` |
| 86 | + |
| 87 | +Then you need to build the new documentation. It is recommended to |
| 88 | +**not use** `-p` first. That way you can check the deployment (gh-pages |
| 89 | +branch) locally and then push upstream. |
| 90 | + |
| 91 | +``` console |
| 92 | +$ mike deploy 0.7.0 latest |
| 93 | +$ mike serve |
| 94 | +``` |
| 95 | + |
| 96 | +Then deploy it (push it to gh-pages), if you want to update the aliases, for |
| 97 | +example to release a new latest. Use the `-u` option when deploying. |
| 98 | + |
| 99 | +``` console |
| 100 | +$ mike deploy 0.7.0 latest -p -u |
| 101 | +``` |
| 102 | + |
| 103 | +**Warning**: after deploying you will get the `site/` folder. There is |
| 104 | +no need to commit it since it will be created each time you deploy. |
| 105 | + |
| 106 | +Finally, you should tag it and push it to github so it stays versioned. |
| 107 | +Note that you have pushed built documentation, but if you wish to be able |
| 108 | +to edit it in the future you need to save its source files. |
| 109 | + |
| 110 | +``` console |
| 111 | +$ git tag v0.7.0 |
| 112 | +$ git push origin v0.7.0 |
| 113 | +``` |
| 114 | + |
| 115 | +#### Editing previous versions of the documentation |
| 116 | + |
| 117 | +As mentioned above, when deploying we do not store the source files. Those |
| 118 | +are stored in the git tags. Therefore, to edit previous documentation we |
| 119 | +should edit those. |
| 120 | + |
| 121 | +Then delete the old version of the docs and re-deploy: |
| 122 | + |
| 123 | +```console |
| 124 | +$ git checkout 0.6.3 |
| 125 | +$ mike delete 0.6.3 -p |
| 126 | +$ # Perform edits, add and commit |
| 127 | +$ git tag 0.6.4 # Or delete the old tag to keep it consistent with the InvenioRDM versions |
| 128 | +$ mike deploy 0.6.3 -p |
| 129 | +``` |
| 130 | + |
| 131 | +More docs [here](https://github.com/jimporter/mike). |
0 commit comments