Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0380ca3

Browse files
Nils Lindemanntiangolo
andauthored
📝 Review and rewording of en/docs/contributing.md (#10480)
Co-authored-by: Sebastián Ramírez <[email protected]>
1 parent 3325635 commit 0380ca3

File tree

1 file changed

+40
-31
lines changed

1 file changed

+40
-31
lines changed

docs/en/docs/contributing.md

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ First, you might want to see the basic ways to [help FastAPI and get help](help-
44

55
## Developing
66

7-
If you already cloned the repository and you know that you need to deep dive in the code, here are some guidelines to set up your environment.
7+
If you already cloned the <a href="https://github.com/tiangolo/fastapi" class="external-link" target="_blank">fastapi repository</a> and you want to deep dive in the code, here are some guidelines to set up your environment.
88

99
### Virtual environment with `venv`
1010

11-
You can create a virtual environment in a directory using Python's `venv` module:
11+
You can create an isolated virtual local environment in a directory using Python's `venv` module. Let's do this in the cloned repository (where the `requirements.txt` is):
1212

1313
<div class="termy">
1414

@@ -18,7 +18,7 @@ $ python -m venv env
1818

1919
</div>
2020

21-
That will create a directory `./env/` with the Python binaries and then you will be able to install packages for that isolated environment.
21+
That will create a directory `./env/` with the Python binaries, and then you will be able to install packages for that local environment.
2222

2323
### Activate the environment
2424

@@ -84,7 +84,7 @@ To check it worked, use:
8484

8585
If it shows the `pip` binary at `env/bin/pip` then it worked. 🎉
8686

87-
Make sure you have the latest pip version on your virtual environment to avoid errors on the next steps:
87+
Make sure you have the latest pip version on your local environment to avoid errors on the next steps:
8888

8989
<div class="termy">
9090

@@ -101,7 +101,7 @@ $ python -m pip install --upgrade pip
101101

102102
This makes sure that if you use a terminal program installed by that package, you use the one from your local environment and not any other that could be installed globally.
103103

104-
### pip
104+
### Install requirements using pip
105105

106106
After activating the environment as described above:
107107

@@ -117,20 +117,20 @@ $ pip install -r requirements.txt
117117

118118
It will install all the dependencies and your local FastAPI in your local environment.
119119

120-
#### Using your local FastAPI
120+
### Using your local FastAPI
121121

122-
If you create a Python file that imports and uses FastAPI, and run it with the Python from your local environment, it will use your local FastAPI source code.
122+
If you create a Python file that imports and uses FastAPI, and run it with the Python from your local environment, it will use your cloned local FastAPI source code.
123123

124124
And if you update that local FastAPI source code when you run that Python file again, it will use the fresh version of FastAPI you just edited.
125125

126126
That way, you don't have to "install" your local version to be able to test every change.
127127

128128
!!! note "Technical Details"
129-
This only happens when you install using this included `requirements.txt` instead of installing `pip install fastapi` directly.
129+
This only happens when you install using this included `requirements.txt` instead of running `pip install fastapi` directly.
130130

131-
That is because inside of the `requirements.txt` file, the local version of FastAPI is marked to be installed in "editable" mode, with the `-e` option.
131+
That is because inside the `requirements.txt` file, the local version of FastAPI is marked to be installed in "editable" mode, with the `-e` option.
132132

133-
### Format
133+
### Format the code
134134

135135
There is a script that you can run that will format and clean all your code:
136136

@@ -227,15 +227,13 @@ And those Python files are included/injected in the documentation when generatin
227227

228228
Most of the tests actually run against the example source files in the documentation.
229229

230-
This helps making sure that:
230+
This helps to make sure that:
231231

232-
* The documentation is up to date.
232+
* The documentation is up-to-date.
233233
* The documentation examples can be run as is.
234234
* Most of the features are covered by the documentation, ensured by test coverage.
235235

236-
237-
238-
### Apps and docs at the same time
236+
#### Apps and docs at the same time
239237

240238
If you run the examples with, e.g.:
241239

@@ -259,7 +257,9 @@ Here are the steps to help with translations.
259257

260258
#### Tips and guidelines
261259

262-
* Check the currently <a href="https://github.com/tiangolo/fastapi/pulls" class="external-link" target="_blank">existing pull requests</a> for your language and add reviews requesting changes or approving them.
260+
* Check the currently <a href="https://github.com/tiangolo/fastapi/pulls" class="external-link" target="_blank">existing pull requests</a> for your language. You can filter the pull requests by the ones with the label for your language. For example, for Spanish, the label is <a href="https://github.com/tiangolo/fastapi/pulls?q=is%3Aopen+sort%3Aupdated-desc+label%3Alang-es+label%3Aawaiting-review" class="external-link" target="_blank">`lang-es`</a>.
261+
262+
* Review those pull requests, requesting changes or approving them. For the languages I don't speak, I'll wait for several others to review the translation before merging.
263263

264264
!!! tip
265265
You can <a href="https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/commenting-on-a-pull-request" class="external-link" target="_blank">add comments with change suggestions</a> to existing pull requests.
@@ -268,19 +268,9 @@ Here are the steps to help with translations.
268268

269269
* Check if there's a <a href="https://github.com/tiangolo/fastapi/discussions/categories/translations" class="external-link" target="_blank">GitHub Discussion</a> to coordinate translations for your language. You can subscribe to it, and when there's a new pull request to review, an automatic comment will be added to the discussion.
270270

271-
* Add a single pull request per page translated. That will make it much easier for others to review it.
272-
273-
For the languages I don't speak, I'll wait for several others to review the translation before merging.
271+
* If you translate pages, add a single pull request per page translated. That will make it much easier for others to review it.
274272

275-
* You can also check if there are translations for your language and add a review to them, that will help me know that the translation is correct and I can merge it.
276-
* You could check in the <a href="https://github.com/tiangolo/fastapi/discussions/categories/translations" class="external-link" target="_blank">GitHub Discussions</a> for your language.
277-
* Or you can filter the existing PRs by the ones with the label for your language, for example, for Spanish, the label is <a href="https://github.com/tiangolo/fastapi/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc+label%3Alang-es+label%3A%22awaiting+review%22" class="external-link" target="_blank">`lang-es`</a>.
278-
279-
* Use the same Python examples and only translate the text in the docs. You don't have to change anything for this to work.
280-
281-
* Use the same images, file names, and links. You don't have to change anything for it to work.
282-
283-
* To check the 2-letter code for the language you want to translate you can use the table <a href="https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes" class="external-link" target="_blank">List of ISO 639-1 codes</a>.
273+
* To check the 2-letter code for the language you want to translate, you can use the table <a href="https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes" class="external-link" target="_blank">List of ISO 639-1 codes</a>.
284274

285275
#### Existing language
286276

@@ -323,7 +313,7 @@ $ python ./scripts/docs.py live es
323313

324314
Now you can go to <a href="http://127.0.0.1:8008" class="external-link" target="_blank">http://127.0.0.1:8008</a> and see your changes live.
325315

326-
You will see that every language has all the pages. But some pages are not translated and have a notification about the missing translation.
316+
You will see that every language has all the pages. But some pages are not translated and have an info box at the top, about the missing translation.
327317

328318
Now let's say that you want to add a translation for the section [Features](features.md){.internal-link target=_blank}.
329319

@@ -342,7 +332,7 @@ docs/es/docs/features.md
342332
!!! tip
343333
Notice that the only change in the path and file name is the language code, from `en` to `es`.
344334

345-
If you go to your browser you will see that now the docs show your new section. 🎉
335+
If you go to your browser you will see that now the docs show your new section (the info box at the top is gone). 🎉
346336

347337
Now you can translate it all and see how it looks as you save the file.
348338

@@ -386,7 +376,7 @@ You can make the first pull request with those two files, `docs/ht/mkdocs.yml` a
386376

387377
#### Preview the result
388378

389-
You can use the `./scripts/docs.py` with the `live` command to preview the results (or `mkdocs serve`).
379+
As already mentioned above, you can use the `./scripts/docs.py` with the `live` command to preview the results (or `mkdocs serve`).
390380

391381
Once you are done, you can also test it all as it would look online, including all the other languages.
392382

@@ -423,6 +413,25 @@ Serving at: http://127.0.0.1:8008
423413

424414
</div>
425415

416+
#### Translation specific tips and guidelines
417+
418+
* Translate only the Markdown documents (`.md`). Do not translate the code examples at `./docs_src`.
419+
420+
* In code blocks within the Markdown document, translate comments (`# a comment`), but leave the rest unchanged.
421+
422+
* Do not change anything enclosed in "``" (inline code).
423+
424+
* In lines starting with `===` or `!!!`, translate only the ` "... Text ..."` part. Leave the rest unchanged.
425+
426+
* You can translate info boxes like `!!! warning` with for example `!!! warning "Achtung"`. But do not change the word immediately after the `!!!`, it determines the color of the info box.
427+
428+
* Do not change the paths in links to images, code files, Markdown documents.
429+
430+
* However, when a Markdown document is translated, the `#hash-parts` in links to its headings may change. Update these links if possible.
431+
* Search for such links in the translated document using the regex `#[^# ]`.
432+
* Search in all documents already translated into your language for `your-translated-document.md`. For example VS Code has an option "Edit" -> "Find in Files".
433+
* When translating a document, do not "pre-translate" `#hash-parts` that link to headings in untranslated documents.
434+
426435
## Tests
427436

428437
There is a script that you can run locally to test all the code and generate coverage reports in HTML:

0 commit comments

Comments
 (0)