| 1 |
# Test translation fixer tool { #test-translation-fixer } |
| 2 |
|
| 3 |
## Code blocks with and without comments { #code-blocks-with-and-without-comments } |
| 4 |
|
| 5 |
This is a test page for the translation fixer tool. |
| 6 |
|
| 7 |
### Code blocks with comments { #code-blocks-with-comments } |
| 8 |
|
| 9 |
The following code blocks include comments in different styles. |
| 10 |
Fixer tool should fix content, but preserve comments correctly. |
| 11 |
|
| 12 |
```python |
| 13 |
# This is a sample Python code block |
| 14 |
def hello_world(): |
| 15 |
# Comment with indentation |
| 16 |
print("Hello, world!") # Print greeting |
| 17 |
``` |
| 18 |
|
| 19 |
```toml |
| 20 |
# This is a sample TOML code block |
| 21 |
title = "TOML Example" # Title of the document |
| 22 |
``` |
| 23 |
|
| 24 |
```console |
| 25 |
// Use the command "live" and pass the language code as a CLI argument |
| 26 |
$ python ./scripts/docs.py live es |
| 27 |
|
| 28 |
<span style="color: green;">[INFO]</span> Serving on http://127.0.0.1:8008 |
| 29 |
<span style="color: green;">[INFO]</span> Start watching changes |
| 30 |
<span style="color: green;">[INFO]</span> Start detecting changes |
| 31 |
``` |
| 32 |
|
| 33 |
```json |
| 34 |
{ |
| 35 |
// This is a sample JSON code block |
| 36 |
"greeting": "Hello, world!" // Greeting |
| 37 |
} |
| 38 |
``` |
| 39 |
|
| 40 |
|
| 41 |
### Code blocks with comments where language uses different comment styles { #code-blocks-with-different-comment-styles } |
| 42 |
|
| 43 |
The following code blocks include comments in different styles based on the language. |
| 44 |
Fixer tool will not preserve comments in these blocks. |
| 45 |
|
| 46 |
```json |
| 47 |
{ |
| 48 |
# This is a sample JSON code block |
| 49 |
"greeting": "Hello, world!" # Print greeting |
| 50 |
} |
| 51 |
``` |
| 52 |
|
| 53 |
```console |
| 54 |
# This is a sample console code block |
| 55 |
$ echo "Hello, world!" # Print greeting |
| 56 |
``` |
| 57 |
|
| 58 |
```toml |
| 59 |
// This is a sample TOML code block |
| 60 |
title = "TOML Example" // Title of the document |
| 61 |
``` |
| 62 |
|
| 63 |
|
| 64 |
### Code blocks with comments with unsupported languages or without language specified { #code-blocks-with-unsupported-languages } |
| 65 |
|
| 66 |
The following code blocks use unsupported languages for comment preservation. |
| 67 |
Fixer tool will not preserve comments in these blocks. |
| 68 |
|
| 69 |
```javascript |
| 70 |
// This is a sample JavaScript code block |
| 71 |
console.log("Hello, world!"); // Print greeting |
| 72 |
``` |
| 73 |
|
| 74 |
``` |
| 75 |
# This is a sample console code block |
| 76 |
$ echo "Hello, world!" # Print greeting |
| 77 |
``` |
| 78 |
|
| 79 |
``` |
| 80 |
// This is a sample console code block |
| 81 |
$ echo "Hello, world!" // Print greeting |
| 82 |
``` |
| 83 |
|
| 84 |
|
| 85 |
### Code blocks with comments that don't follow pattern { #code-blocks-with-comments-without-pattern } |
| 86 |
|
| 87 |
Fixer tool expects comments that follow specific pattern: |
| 88 |
|
| 89 |
- For hash-style comments: comment starts with `# ` (hash following by whitespace) in the beginning of the string or after a whitespace. |
| 90 |
- For slash-style comments: comment starts with `// ` (two slashes following by whitespace) in the beginning of the string or after a whitespace. |
| 91 |
|
| 92 |
If comment doesn't follow this pattern, fixer tool will not preserve it. |
| 93 |
|
| 94 |
```python |
| 95 |
#Function declaration |
| 96 |
def hello_world():# Print greeting |
| 97 |
print("Hello, world!") #Print greeting without space after hash |
| 98 |
``` |
| 99 |
|
| 100 |
```console |
| 101 |
//Function declaration |
| 102 |
def hello_world():// Print greeting |
| 103 |
print("Hello, world!") //Print greeting without space after slashes |
| 104 |
``` |
| 105 |
|
| 106 |
## Code blocks with quadruple backticks { #code-blocks-with-quadruple-backticks } |
| 107 |
|
| 108 |
The following code block uses quadruple backticks. |
| 109 |
|
| 110 |
````python |
| 111 |
# Hello world function |
| 112 |
def hello_world(): |
| 113 |
print("Hello, world!") # Print greeting |
| 114 |
```` |
| 115 |
|
| 116 |
### Backticks number mismatch is fixable { #backticks-number-mismatch-is-fixable } |
| 117 |
|
| 118 |
The following code block has triple backticks in the original document, but quadruple backticks in the translated document. |
| 119 |
It will be fixed by the fixer tool (will convert to triple backticks). |
| 120 |
|
| 121 |
```Python |
| 122 |
# Some Python code |
| 123 |
``` |
| 124 |
|
| 125 |
### Triple backticks inside quadruple backticks { #triple-backticks-inside-quadruple-backticks } |
| 126 |
|
| 127 |
Comments inside nested code block will NOT be preserved. |
| 128 |
|
| 129 |
```` |
| 130 |
Here is a code block with quadruple backticks that contains triple backticks inside: |
| 131 |
|
| 132 |
```python |
| 133 |
# This is a sample Python code block |
| 134 |
def hello_world(): |
| 135 |
print("Hello, world!") # Print greeting |
| 136 |
``` |
| 137 |
|
| 138 |
```` |
| 139 |
|
| 140 |
# Code includes { #code-includes } |
| 141 |
|
| 142 |
## Simple code includes { #simple-code-includes } |
| 143 |
|
| 144 |
{* ../../docs_src/python_types/tutorial001_py310.py *} |
| 145 |
|
| 146 |
{* ../../docs_src/python_types/tutorial002_py310.py *} |
| 147 |
|
| 148 |
|
| 149 |
## Code includes with highlighting { #code-includes-with-highlighting } |
| 150 |
|
| 151 |
{* ../../docs_src/python_types/tutorial002_py310.py hl[1] *} |
| 152 |
|
| 153 |
{* ../../docs_src/python_types/tutorial006_py310.py hl[10] *} |
| 154 |
|
| 155 |
|
| 156 |
## Code includes with line ranges { #code-includes-with-line-ranges } |
| 157 |
|
| 158 |
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[19:21] *} |
| 159 |
|
| 160 |
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[30:38] *} |
| 161 |
|
| 162 |
|
| 163 |
## Code includes with line ranges and highlighting { #code-includes-with-line-ranges-and-highlighting } |
| 164 |
|
| 165 |
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[30:38] hl[31:33] *} |
| 166 |
|
| 167 |
{* ../../docs_src/dependencies/tutorial015_an_py310.py ln[10:15] hl[12:14] *} |
| 168 |
|
| 169 |
|
| 170 |
## Code includes qith title { #code-includes-with-title } |
| 171 |
|
| 172 |
{* ../../docs_src/bigger_applications/app_an_py310/routers/users.py hl[1,3] title["app/routers/users.py"] *} |
| 173 |
|
| 174 |
{* ../../docs_src/bigger_applications/app_an_py310/internal/admin.py hl[3] title["app/internal/admin.py"] *} |
| 175 |
|
| 176 |
## Code includes with unknown attributes { #code-includes-with-unknown-attributes } |
| 177 |
|
| 178 |
{* ../../docs_src/python_types/tutorial001_py310.py unknown[123] *} |
| 179 |
|
| 180 |
## Some more code includes to test fixing { #some-more-code-includes-to-test-fixing } |
| 181 |
|
| 182 |
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[19:21] *} |
| 183 |
|
| 184 |
{* ../../docs_src/bigger_applications/app_an_py310/internal/admin.py hl[3] title["app/internal/admin.py"] *} |
| 185 |
|
| 186 |
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[30:38] hl[31:33] *} |
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
# Links { #links } |
| 191 |
|
| 192 |
## Markdown-style links { #markdown-style-links } |
| 193 |
|
| 194 |
This is a [Markdown link](https://example.com) to an external site. |
| 195 |
|
| 196 |
This is a link with attributes: [**FastAPI** Project Generators](project-generation.md){.internal-link target=_blank} |
| 197 |
|
| 198 |
This is a link to the main FastAPI site: [FastAPI](https://fastapi.tiangolo.com) - tool should add language code to the URL. |
| 199 |
|
| 200 |
This is a link to one of the pages on FastAPI site: [How to](https://fastapi.tiangolo.com/how-to/) - tool should add language code to the URL. |
| 201 |
|
| 202 |
Link to test wrong attribute: [**FastAPI** Project Generators](project-generation.md){.internal-link} - tool should fix the attribute. |
| 203 |
|
| 204 |
Link with a title: [Example](https://example.com "Example site") - URL will be fixed, title preserved. |
| 205 |
|
| 206 |
### Markdown link to static assets { #markdown-link-to-static-assets } |
| 207 |
|
| 208 |
These are links to static assets: |
| 209 |
|
| 210 |
* [FastAPI Logo](https://fastapi.tiangolo.com/img/fastapi-logo.png) |
| 211 |
* [FastAPI CSS](https://fastapi.tiangolo.com/css/fastapi.css) |
| 212 |
* [FastAPI JS](https://fastapi.tiangolo.com/js/fastapi.js) |
| 213 |
|
| 214 |
Tool should NOT add language code to their URLs. |
| 215 |
|
| 216 |
## HTML-style links { #html-style-links } |
| 217 |
|
| 218 |
This is an <a href="https://example.com" target="_blank" class="external-link">HTML link</a> to an external site. |
| 219 |
|
| 220 |
This is an <a href="https://fastapi.tiangolo.com">link to the main FastAPI site</a> - tool should add language code to the URL. |
| 221 |
|
| 222 |
This is an <a href="https://fastapi.tiangolo.com/how-to/">link to one of the pages on FastAPI site</a> - tool should add language code to the URL. |
| 223 |
|
| 224 |
Link to test wrong attribute: <a href="project-generation.md" class="internal-link">**FastAPI** Project Generators</a> - tool should fix the attribute. |
| 225 |
|
| 226 |
### HTML links to static assets { #html-links-to-static-assets } |
| 227 |
|
| 228 |
These are links to static assets: |
| 229 |
|
| 230 |
* <a href="https://fastapi.tiangolo.com/img/fastapi-logo.png">FastAPI Logo</a> |
| 231 |
* <a href="https://fastapi.tiangolo.com/css/fastapi.css">FastAPI CSS</a> |
| 232 |
* <a href="https://fastapi.tiangolo.com/js/fastapi.js">FastAPI JS</a> |
| 233 |
|
| 234 |
Tool should NOT add language code to their URLs. |
| 235 |
|
| 236 |
# Header (with HTML link to <a href="https://tiangolo.com">tiangolo.com</a>) { #header-with-html-link-to-tiangolo-com } |
| 237 |
|
| 238 |
#Not a header |
| 239 |
|
| 240 |
```Python |
| 241 |
# Also not a header |
| 242 |
``` |
| 243 |
|
| 244 |
Some text |