Skip to content

Commit 7f8c718

Browse files
committed
Fix contributing.md
1 parent 78d7f30 commit 7f8c718

File tree

2 files changed

+192
-192
lines changed

2 files changed

+192
-192
lines changed

CONTRIBUTING.md

+96-96
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
## Python development setup
2-
32
---
43

54
- Fork and clone the repository
@@ -8,57 +7,58 @@
87

98
- Install repository in editable mode with development dependencies:
109

11-
```bash
12-
cd python
13-
pip install -e ".[dev]"
14-
```
10+
```bash
11+
cd python
12+
pip install -e ".[dev]"
13+
```
1514

1615
- Install [pre-commit](https://pre-commit.com/) and then activate its hooks. pre-commit is a framework for managing and maintaining multi-language pre-commit hooks. The library uses pre-commit to ensure code-style and code formatting through [black](https://github.com/psf/black) and [flake8](https://gitlab.com/pycqa/flake8). Run the following commands from the `python` directory:
1716

18-
```bash
19-
cd python
20-
pip install --user pre-commit
21-
pre-commit install
22-
```
17+
```bash
18+
cd python
19+
pip install --user pre-commit
20+
pre-commit install
21+
```
2322

2423
Afterwards, pre-commit will run whenever you commit.
2524

2625
- To run formatting and code-style separately, you can configure your IDE, such as VSCode, to use black and flake8, or run them via the command line:
2726

28-
```bash
29-
cd python
30-
flake8 hopsworks
31-
black hopsworks
32-
```
27+
```bash
28+
cd python
29+
flake8 hopsworks
30+
black hopsworks
31+
```
3332

3433
### Python documentation
3534

3635
We follow a few best practices for writing the Python documentation:
3736

3837
1. Use the google docstring style:
3938

40-
```python
41-
"""[One Line Summary]
39+
```python
40+
"""[One Line Summary]
4241
43-
[Extended Summary]
42+
[Extended Summary]
4443
45-
[!!! example
46-
import xyz
47-
]
44+
[!!! example
45+
import xyz
46+
]
4847
49-
# Arguments
50-
arg1: Type[, optional]. Description[, defaults to `default`]
51-
arg2: Type[, optional]. Description[, defaults to `default`]
48+
# Arguments
49+
arg1: Type[, optional]. Description[, defaults to `default`]
50+
arg2: Type[, optional]. Description[, defaults to `default`]
5251
53-
# Returns
54-
Type. Description.
52+
# Returns
53+
Type. Description.
5554
56-
# Raises
57-
Exception. Description.
58-
"""
59-
```
55+
# Raises
56+
Exception. Description.
57+
"""
58+
```
59+
60+
If Python 3 type annotations are used, they are inserted automatically.
6061

61-
If Python 3 type annotations are used, they are inserted automatically.
6262

6363
2. Hopsworks entity engine methods (e.g. ExecutionEngine etc.) only require a single line docstring.
6464
3. Private REST Api implementations (e.g. GitRemoteApi etc.) should be fully documented with docstrings without defaults.
@@ -69,42 +69,42 @@ We follow a few best practices for writing the Python documentation:
6969
We use `mkdocs` together with `mike` ([for versioning](https://github.com/jimporter/mike/)) to build the documentation and a plugin called `keras-autodoc` to auto generate Python API documentation from docstrings.
7070

7171
**Background about `mike`:**
72-
`mike` builds the documentation and commits it as a new directory to the gh-pages branch. Each directory corresponds to one version of the documentation. Additionally, `mike` maintains a json in the root of gh-pages with the mappings of versions/aliases for each of the directories available. With aliases you can define extra names like `dev` or `latest`, to indicate stable and unstable releases.
72+
`mike` builds the documentation and commits it as a new directory to the gh-pages branch. Each directory corresponds to one version of the documentation. Additionally, `mike` maintains a json in the root of gh-pages with the mappings of versions/aliases for each of the directories available. With aliases you can define extra names like `dev` or `latest`, to indicate stable and unstable releases.
7373

7474
1. Currently we are using our own version of `keras-autodoc`
7575

76-
```bash
77-
pip install git+https://github.com/logicalclocks/keras-autodoc
78-
```
76+
```bash
77+
pip install git+https://github.com/logicalclocks/keras-autodoc
78+
```
7979

8080
2. Install HOPSWORKS with `docs` extras:
8181

82-
```bash
83-
pip install -e .[dev,docs]
84-
```
82+
```bash
83+
pip install -e .[dev,docs]
84+
```
8585

8686
3. To build the docs, first run the auto doc script:
8787

88-
```bash
89-
cd ..
90-
python auto_doc.py
91-
```
88+
```bash
89+
cd ..
90+
python auto_doc.py
91+
```
9292

9393
##### Option 1: Build only current version of docs
9494

9595
4. Either build the docs, or serve them dynamically:
9696

97-
Note: Links and pictures might not resolve properly later on when checking with this build.
98-
The reason for that is that the docs are deployed with versioning on docs.hopsworks.ai and
99-
therefore another level is added to all paths, e.g. `docs.hopsworks.ai/[version-or-alias]`.
100-
Using relative links should not be affected by this, however, building the docs with version
101-
(Option 2) is recommended.
97+
Note: Links and pictures might not resolve properly later on when checking with this build.
98+
The reason for that is that the docs are deployed with versioning on docs.hopsworks.ai and
99+
therefore another level is added to all paths, e.g. `docs.hopsworks.ai/[version-or-alias]`.
100+
Using relative links should not be affected by this, however, building the docs with version
101+
(Option 2) is recommended.
102102

103-
```bash
104-
mkdocs build
105-
# or
106-
mkdocs serve
107-
```
103+
```bash
104+
mkdocs build
105+
# or
106+
mkdocs serve
107+
```
108108

109109
##### Option 2 (Preferred): Build multi-version doc with `mike`
110110

@@ -118,62 +118,62 @@ On docs.hopsworks.ai we implement the following versioning scheme:
118118

119119
###### Build Instructions
120120

121-
4. For this you can either checkout and make a local copy of the `upstream/gh-pages` branch, where
122-
`mike` maintains the current state of docs.hopsworks.ai, or just build documentation for the branch you are updating:
121+
4. For this you can either checkout and make a local copy of the `upstream/gh-pages` branch, where
122+
`mike` maintains the current state of docs.hopsworks.ai, or just build documentation for the branch you are updating:
123123

124-
Building *one* branch:
124+
Building *one* branch:
125125

126-
Checkout your dev branch with modified docs:
127-
```bash
128-
git checkout [dev-branch]
129-
```
126+
Checkout your dev branch with modified docs:
127+
```bash
128+
git checkout [dev-branch]
129+
```
130130

131-
Generate API docs if necessary:
132-
```bash
133-
python auto_doc.py
134-
```
131+
Generate API docs if necessary:
132+
```bash
133+
python auto_doc.py
134+
```
135135

136-
Build docs with a version and alias
137-
```bash
138-
mike deploy [version] [alias] --update-alias
136+
Build docs with a version and alias
137+
```bash
138+
mike deploy [version] [alias] --update-alias
139139
140-
# for example, if you are updating documentation to be merged to master,
141-
# which will become the new SNAPSHOT version:
142-
mike deploy 3.1.0-SNAPSHOT dev --update-alias
140+
# for example, if you are updating documentation to be merged to master,
141+
# which will become the new SNAPSHOT version:
142+
mike deploy 3.1.0-SNAPSHOT dev --update-alias
143143
144-
# if you are updating docs of the latest stable release branch
145-
mike deploy [version] latest --update-alias
144+
# if you are updating docs of the latest stable release branch
145+
mike deploy [version] latest --update-alias
146146
147-
# if you are updating docs of a previous stable release branch
148-
mike deploy [version]
149-
```
147+
# if you are updating docs of a previous stable release branch
148+
mike deploy [version]
149+
```
150150

151-
If no gh-pages branch existed in your local repository, this will have created it.
151+
If no gh-pages branch existed in your local repository, this will have created it.
152152

153-
**Important**: If no previous docs were built, you will have to choose a version as default to be loaded as index, as follows
153+
**Important**: If no previous docs were built, you will have to choose a version as default to be loaded as index, as follows
154154

155-
```bash
156-
mike set-default [version-or-alias]
157-
```
155+
```bash
156+
mike set-default [version-or-alias]
157+
```
158158

159-
You can now checkout the gh-pages branch and serve:
160-
```bash
161-
git checkout gh-pages
162-
mike serve
163-
```
159+
You can now checkout the gh-pages branch and serve:
160+
```bash
161+
git checkout gh-pages
162+
mike serve
163+
```
164164

165-
You can also list all available versions/aliases:
166-
```bash
167-
mike list
168-
```
165+
You can also list all available versions/aliases:
166+
```bash
167+
mike list
168+
```
169169

170-
Delete and reset your local gh-pages branch:
171-
```bash
172-
mike delete --all
170+
Delete and reset your local gh-pages branch:
171+
```bash
172+
mike delete --all
173173
174-
# or delete single version
175-
mike delete [version-or-alias]
176-
```
174+
# or delete single version
175+
mike delete [version-or-alias]
176+
```
177177

178178
#### Adding new API documentation
179179

@@ -193,7 +193,7 @@ PAGES = {
193193

194194
Now you can add a template markdown file to the `docs/templates` directory with the name you specified in the auto-doc script. The `new_template.md` file should contain a tag to identify the place at which the API documentation should be inserted:
195195

196-
````
196+
```
197197
## The XYZ package
198198
199199
{{module}}
@@ -206,7 +206,7 @@ Some extra content here.
206206
```
207207
208208
{{xyz.asd}}
209-
````
209+
```
210210

211211
Finally, run the `auto_doc.py` script, as decribed above, to update the documentation.
212212

0 commit comments

Comments
 (0)