Skip to content

Commit 6292532

Browse files
authored
Update doc writing guide (huggingface#15350)
1 parent 19732cc commit 6292532

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

docs/README.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ check how they look like before committing for instance). You don't have to comm
4040
## Building the documentation
4141

4242
Once you have setup the `doc-builder` and additional packages, you can generate the documentation by typing th
43-
folowwing command:
43+
following command:
4444

4545
```bash
4646
doc-builder build transformers docs/source/ --build_dir ~/tmp/test-build
@@ -53,15 +53,14 @@ Markdown editor.
5353
---
5454
**NOTE**
5555

56-
It's not possible to see locally how the final documentation will look like for now. We are working on solutions to
57-
enable this, but any pre-visualiser of Markdown file should already give you a good idea of the result!
56+
It's not possible to see locally how the final documentation will look like for now. Once you have opened a PR, you
57+
will see a bot add a comment to a link where the documentation with your changes lives.
5858

5959
---
6060

6161
## Adding a new element to the navigation bar
6262

63-
Accepted files are reStructuredText (.rst) and Markdown (.md or .mdx). We are progressively moving away from rst so you should
64-
create any new documentation file in the .mdx format.
63+
Accepted files are Markdown (.md or .mdx).
6564

6665
Create a file with its extension and put it in the source directory. You can then link it to the toc-tree by putting
6766
the filename without the extension in the [`_toctree.yml`](https://github.com/huggingface/transformers/blob/master/docs/source/_toctree.yml) file.
@@ -92,17 +91,11 @@ Use the relative style to link to the new file so that the versioned docs contin
9291
For an example of a rich moved sections set please see the very end of [the Trainer doc](https://github.com/huggingface/transformers/blob/master/docs/source/main_classes/trainer.mdx).
9392

9493

95-
## Preview the documentation in a pull request
96-
97-
Coming soon!
98-
9994
## Writing Documentation - Specification
10095

10196
The `huggingface/transformers` documentation follows the
10297
[Google documentation](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) style for docstrings,
103-
although we can write them directly in Markdown. Parts of it are written in ReStructuredText
104-
([Sphinx simple documentation](https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html) but we are
105-
updating those.
98+
although we can write them directly in Markdown.
10699

107100
### Adding a new tutorial
108101

@@ -134,6 +127,8 @@ When adding a new model:
134127
- PyTorch head models
135128
- TensorFlow base model
136129
- TensorFlow head models
130+
- Flax base model
131+
- Flax head models
137132

138133
These classes should be added using our Markdown syntax. Usually as follows:
139134

@@ -179,7 +174,7 @@ function to be in the main package.
179174
If you want to create a link to some internal class or function, you need to
180175
provide its path. For instance: \[\`file_utils.ModelOutput\`\]. This will be converted into a link with
181176
`file_utils.ModelOutput` in the description. To get rid of the path and only keep the name of the object you are
182-
linking to, add a ~: \[\`~file_utils.ModelOutput\`\] will generate a link with `ModelOutput` in the description.
177+
linking to in the description, add a ~: \[\`~file_utils.ModelOutput\`\] will generate a link with `ModelOutput` in the description.
183178

184179
The same wroks for methods so you can either use \[\`XXXClass.method\`\] or \[~\`XXXClass.method\`\].
185180

@@ -279,3 +274,12 @@ them by URL. We recommend putting them in the following dataset: [huggingface/do
279274
If an external contribution, feel free to add the images to your PR and ask a Hugging Face member to migrate your images
280275
to this dataset.
281276

277+
## Styling the docstring
278+
279+
We have an automatic script running with the `make style` comment that will make sure that:
280+
- the docstrings fully take advantage of the line width
281+
- all code examples are formatted using black, like the code of the Transformers library
282+
283+
This script may have some weird failures if you made a syntax mistake or if you uncover a bug. Therefore, it's
284+
recommended to commit your changes before running `make style`, so you can revert the changes done by that script
285+
easily.

0 commit comments

Comments
 (0)