You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
58
58
59
59
---
60
60
61
61
## Adding a new element to the navigation bar
62
62
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).
65
64
66
65
Create a file with its extension and put it in the source directory. You can then link it to the toc-tree by putting
67
66
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
92
91
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).
93
92
94
93
95
-
## Preview the documentation in a pull request
96
-
97
-
Coming soon!
98
-
99
94
## Writing Documentation - Specification
100
95
101
96
The `huggingface/transformers` documentation follows the
102
97
[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.
106
99
107
100
### Adding a new tutorial
108
101
@@ -134,6 +127,8 @@ When adding a new model:
134
127
- PyTorch head models
135
128
- TensorFlow base model
136
129
- TensorFlow head models
130
+
- Flax base model
131
+
- Flax head models
137
132
138
133
These classes should be added using our Markdown syntax. Usually as follows:
139
134
@@ -179,7 +174,7 @@ function to be in the main package.
179
174
If you want to create a link to some internal class or function, you need to
180
175
provide its path. For instance: \[\`file_utils.ModelOutput\`\]. This will be converted into a link with
181
176
`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.
183
178
184
179
The same wroks for methods so you can either use \[\`XXXClass.method\`\] or \[~\`XXXClass.method\`\].
185
180
@@ -279,3 +274,12 @@ them by URL. We recommend putting them in the following dataset: [huggingface/do
279
274
If an external contribution, feel free to add the images to your PR and ask a Hugging Face member to migrate your images
280
275
to this dataset.
281
276
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
0 commit comments