Skip to content

Commit 2d5def5

Browse files
committed
Add markdownlint
Add `markdownlint` linter and fix issues. Config is based on the one from electron's repo with a few rules relaxed.
1 parent 6554d51 commit 2d5def5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1200
-746
lines changed

Diff for: .editorconfig

-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,3 @@ indent_style = tab
2626

2727
[*.svg]
2828
insert_final_newline = false
29-
30-
[*.md]
31-
trim_trailing_whitespace = false

Diff for: .markdownlint.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
commands-show-output: false
2+
fenced-code-language: false
3+
first-line-h1: false
4+
header-increment: false
5+
line-length: {code_blocks: false, tables: false, stern: true, line_length: -1}
6+
no-alt-text: false
7+
no-bare-urls: false
8+
no-blanks-blockquote: false
9+
no-duplicate-header: {allow_different_nesting: true}
10+
no-emphasis-as-header: false
11+
no-empty-links: false
12+
no-hard-tabs: {code_blocks: false}
13+
no-inline-html: false
14+
no-space-in-code: false
15+
no-space-in-emphasis: false
16+
no-trailing-punctuation: false
17+
no-trailing-spaces: {br_spaces: 0}
18+
single-h1: false

Diff for: Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ lint-frontend: node_modules
313313
npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js docs/assets/js
314314
npx stylelint --color --max-warnings=0 web_src/less
315315
npx spectral lint -q -F hint $(SWAGGER_SPEC)
316+
npx markdownlint docs
316317

317318
.PHONY: lint-backend
318319
lint-backend: golangci-lint vet editorconfig-checker

Diff for: docs/content/doc/advanced/clone-filter.en-us.md

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ see Git version of the server.
3030
By default, clone filters are enabled, unless `DISABLE_PARTIAL_CLONE` under
3131
`[git]` is set to `true`.
3232

33-
3433
See [GitHub blog post: Get up to speed with partial clone](https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/)
3534
for common use cases of clone filters (blobless and treeless clones), and
3635
[GitLab docs for partial clone](https://docs.gitlab.com/ee/topics/git/partial_clone.html)

Diff for: docs/content/doc/advanced/config-cheat-sheet.en-us.md

+61-47
Large diffs are not rendered by default.

Diff for: docs/content/doc/advanced/config-cheat-sheet.zh-cn.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ menu:
173173
- `ADAPTER`: **memory**: 缓存引擎,可以为 `memory`, `redis``memcache`
174174
- `INTERVAL`: **60**: 只对内存缓存有效,GC间隔,单位秒。
175175
- `HOST`: **\<empty\>**: 针对redis和memcache有效,主机地址和端口。
176-
- Redis: `network=tcp,addr=127.0.0.1:6379,password=macaron,db=0,pool_size=100,idle_timeout=180`
177-
- Memache: `127.0.0.1:9090;127.0.0.1:9091`
176+
- Redis: `network=tcp,addr=127.0.0.1:6379,password=macaron,db=0,pool_size=100,idle_timeout=180`
177+
- Memache: `127.0.0.1:9090;127.0.0.1:9091`
178178
- `ITEM_TTL`: **16h**: 缓存项目失效时间,设置为 -1 则禁用缓存。
179179

180180
## Cache - LastCommitCache settings (`cache.last_commit`)
@@ -239,7 +239,6 @@ file -I test01.xls
239239
test01.xls: application/vnd.ms-excel; charset=binary
240240
```
241241

242-
243242
## Log (`log`)
244243

245244
- `ROOT_PATH`: 日志文件根目录。
@@ -251,10 +250,9 @@ test01.xls: application/vnd.ms-excel; charset=binary
251250
- `ENABLED`: 是否在后台运行定期任务。
252251
- `RUN_AT_START`: 是否启动时自动运行。
253252
- `SCHEDULE` 所接受的格式
254-
- 完整 crontab 控制, 例如 `* * * * * ?`
255-
- 描述符, 例如 `@midnight`, `@every 1h30m` ...
256-
- 更多细节参见 [cron api文档](https://pkg.go.dev/github.com/gogs/[email protected])
257-
253+
- 完整 crontab 控制, 例如 `* * * * * ?`
254+
- 描述符, 例如 `@midnight`, `@every 1h30m` ...
255+
- 更多细节参见 [cron api文档](https://pkg.go.dev/github.com/gogs/[email protected])
258256

259257
### Cron - Update Mirrors (`cron.update_mirrors`)
260258

@@ -440,6 +438,7 @@ Repository archive 的存储配置。 如果 `STORAGE_TYPE` 为空,则此配
440438
- `PROXY_HOSTS`: **\<empty\>**: 逗号分隔的多个需要代理的网址,支持 * 号匹配符号, ** 表示匹配所有网站
441439

442440
i.e.
441+
443442
```ini
444443
PROXY_ENABLED = true
445444
PROXY_URL = socks://127.0.0.1:1080

Diff for: docs/content/doc/advanced/customizing-gitea.en-us.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ copy javascript files from https://gitea.com/davidsvantesson/plantuml-code-highl
149149

150150
You can then add blocks like the following to your markdown:
151151

152-
```plantuml
153-
Alice -> Bob: Authentication Request
154-
Bob --> Alice: Authentication Response
152+
```plantuml
153+
Alice -> Bob: Authentication Request
154+
Bob --> Alice: Authentication Response
155155
156-
Alice -> Bob: Another authentication Request
157-
Alice <-- Bob: Another authentication Response
158-
```
156+
Alice -> Bob: Another authentication Request
157+
Alice <-- Bob: Another authentication Response
158+
```
159159

160160
The script will detect tags with `class="language-plantuml"`, but you can change this by providing a second argument to `parsePlantumlCodeBlocks`.
161161

Diff for: docs/content/doc/advanced/environment-variables.zh-cn.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,31 @@ GITEA_CUSTOM=/home/gitea/custom ./gitea web
2525

2626
因为 Gitea 使用 Go 语言编写,因此它使用了一些相关的 Go 的配置参数:
2727

28-
* `GOOS`
29-
* `GOARCH`
30-
* [`GOPATH`](https://golang.org/cmd/go/#hdr-GOPATH_environment_variable)
28+
* `GOOS`
29+
* `GOARCH`
30+
* [`GOPATH`](https://golang.org/cmd/go/#hdr-GOPATH_environment_variable)
3131

3232
您可以在[官方文档](https://golang.org/cmd/go/#hdr-Environment_variables)中查阅这些配置参数的详细信息。
3333

3434
## Gitea 的文件目录
3535

36-
* `GITEA_WORK_DIR`:工作目录的绝对路径
37-
* `GITEA_CUSTOM`:默认情况下 Gitea 使用默认目录 `GITEA_WORK_DIR`/custom,您可以使用这个参数来配置 *custom* 目录
38-
* `GOGS_WORK_DIR`: 已废弃,请使用 `GITEA_WORK_DIR` 替代
39-
* `GOGS_CUSTOM`: 已废弃,请使用 `GITEA_CUSTOM` 替代
36+
* `GITEA_WORK_DIR`:工作目录的绝对路径
37+
* `GITEA_CUSTOM`:默认情况下 Gitea 使用默认目录 `GITEA_WORK_DIR`/custom,您可以使用这个参数来配置 *custom* 目录
38+
* `GOGS_WORK_DIR`: 已废弃,请使用 `GITEA_WORK_DIR` 替代
39+
* `GOGS_CUSTOM`: 已废弃,请使用 `GITEA_CUSTOM` 替代
4040

4141
## 操作系统配置
4242

43-
* `USER`:Gitea 运行时使用的系统用户,它将作为一些 repository 的访问地址的一部分
44-
* `USERNAME`: 如果没有配置 `USER`, Gitea 将使用 `USERNAME`
45-
* `HOME`: 用户的 home 目录,在 Windows 中会使用 `USERPROFILE` 环境变量
43+
* `USER`:Gitea 运行时使用的系统用户,它将作为一些 repository 的访问地址的一部分
44+
* `USERNAME`: 如果没有配置 `USER`, Gitea 将使用 `USERNAME`
45+
* `HOME`: 用户的 home 目录,在 Windows 中会使用 `USERPROFILE` 环境变量
4646

4747
### 仅限于 Windows 的配置
4848

49-
* `USERPROFILE`: 用户的主目录,如果未配置则会使用 `HOMEDRIVE` + `HOMEPATH`
50-
* `HOMEDRIVE`: 用于访问 home 目录的主驱动器路径(C盘)
51-
* `HOMEPATH`:在指定主驱动器下的 home 目录相对路径
49+
* `USERPROFILE`: 用户的主目录,如果未配置则会使用 `HOMEDRIVE` + `HOMEPATH`
50+
* `HOMEDRIVE`: 用于访问 home 目录的主驱动器路径(C盘)
51+
* `HOMEPATH`:在指定主驱动器下的 home 目录相对路径
5252

5353
## Miscellaneous
5454

55-
* `SKIP_MINWINSVC`:如果设置为 1,在 Windows 上不会以 service 的形式运行。
55+
* `SKIP_MINWINSVC`:如果设置为 1,在 Windows 上不会以 service 的形式运行。

Diff for: docs/content/doc/advanced/external-renderers.en-us.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ ALLOW_ATTR = class
127127
### Example: Office DOCX
128128

129129
Display Office DOCX files with [`pandoc`](https://pandoc.org/):
130+
130131
```ini
131132
[markup.docx]
132133
ENABLED = true
@@ -138,13 +139,15 @@ ALLOW_DATA_URI_IMAGES = true
138139
```
139140

140141
The template file has the following content:
142+
141143
```
142144
$body$
143145
```
144146

145147
### Example: Jupyter Notebook
146148

147149
Display Jupyter Notebook files with [`nbconvert`](https://github.com/jupyter/nbconvert):
150+
148151
```ini
149152
[markup.jupyter]
150153
ENABLED = true
@@ -156,9 +159,11 @@ ALLOW_DATA_URI_IMAGES = true
156159
```
157160

158161
## Customizing CSS
159-
The external renderer is specified in the .ini in the format `[markup.XXXXX]` and the HTML supplied by your external renderer will be wrapped in a `<div>` with classes `markup` and `XXXXX`. The `markup` class provides out of the box styling (as does `markdown` if `XXXXX` is `markdown`). Otherwise you can use these classes to specifically target the contents of your rendered HTML.
162+
163+
The external renderer is specified in the .ini in the format `[markup.XXXXX]` and the HTML supplied by your external renderer will be wrapped in a `<div>` with classes `markup` and `XXXXX`. The `markup` class provides out of the box styling (as does `markdown` if `XXXXX` is `markdown`). Otherwise you can use these classes to specifically target the contents of your rendered HTML.
160164

161165
And so you could write some CSS:
166+
162167
```css
163168
.markup.XXXXX html {
164169
font-size: 100%;
@@ -184,6 +189,7 @@ And so you could write some CSS:
184189
```
185190

186191
Add your stylesheet to your custom directory e.g `custom/public/css/my-style-XXXXX.css` and import it using a custom header file `custom/templates/custom/header.tmpl`:
192+
187193
```html
188194
<link type="text/css" href="{{AppSubUrl}}/assets/css/my-style-XXXXX.css" />
189195
```

Diff for: docs/content/doc/advanced/mail-templates-us.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ This template produces something along these lines:
251251
>
252252
> \_********************************\_********************************
253253
>
254-
> Mike, I think we should tone down the blues a little.
254+
> Mike, I think we should tone down the blues a little.
255255
> \_********************************\_********************************
256256
>
257257
> [View it on Gitea](#).

Diff for: docs/content/doc/advanced/protected-tags.en-us.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ menu:
1515

1616
# Protected tags
1717

18-
Protected tags allow control over who has permission to create or update Git tags. Each rule allows you to match either an individual tag name, or use an appropriate pattern to control multiple tags at once.
18+
Protected tags allow control over who has permission to create or update Git tags. Each rule allows you to match either an individual tag name, or use an appropriate pattern to control multiple tags at once.
1919

2020
**Table of Contents**
2121

Diff for: docs/content/doc/advanced/repo-mirror.en-us.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ For an existing remote repository, you can set up pull mirroring as follows:
3737
3. Enter a repository URL.
3838
4. If the repository needs authentication fill in your authentication information.
3939
5. Check the box **This repository will be a mirror**.
40-
5. Select **Migrate repository** to save the configuration.
40+
6. Select **Migrate repository** to save the configuration.
4141

4242
The repository now gets mirrored periodically from the remote repository. You can force a sync by selecting **Synchronize Now** in the repository settings.
4343

Diff for: docs/content/doc/advanced/search-engines-indexation.en-us.md

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ create a file called `robots.txt` in the [`custom` folder or `CustomPath`]({{< r
2525

2626
Examples on how to configure the `robots.txt` can be found at [https://moz.com/learn/seo/robotstxt](https://moz.com/learn/seo/robotstxt).
2727

28-
2928
```txt
3029
User-agent: *
3130
Disallow: /

Diff for: docs/content/doc/advanced/third-party-tools.zh-cn.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,26 @@ menu:
1414
---
1515

1616
# 第三方工具列表
17+
1718
**注意:** 这些工具并没有经过Gitea的检验,在这里列出它们只是为了便捷.
1819

1920
*此列表并不是完整的列表,可以随时咨询如何添加!*
2021

2122
### 持续集成
22-
[BuildKite 连接器](https://github.com/techknowlogick/gitea-buildkite-connector)
23-
[Jenkins 插件](https://github.com/jenkinsci/gitea-plugin)
24-
[Gitea搭配Drone](https://docs.drone.io/installation/gitea)
2523

24+
[BuildKite 连接器](https://github.com/techknowlogick/gitea-buildkite-connector)
25+
[Jenkins 插件](https://github.com/jenkinsci/gitea-plugin)
26+
[Gitea搭配Drone](https://docs.drone.io/installation/gitea)
2627

2728
### 迁移
28-
[Gitea安装脚本](https://git.coolaj86.com/coolaj86/gitea-installer.sh)
29-
[GitHub迁移](https://gitea.com/gitea/migrator)
3029

30+
[Gitea安装脚本](https://git.coolaj86.com/coolaj86/gitea-installer.sh)
31+
[GitHub迁移](https://gitea.com/gitea/migrator)
3132

3233
### 移动端
34+
3335
[安卓客户端GitNex](https://gitlab.com/mmarif4u/gitnex)
3436

35-
### 编辑器扩展
36-
- [Gitea的Visual Studio扩展](https://github.com/maikebing/Gitea.VisualStudio)[Visual Studio 扩展市场](https://marketplace.visualstudio.com/items?itemName=MysticBoy.GiteaExtensionforVisualStudio) 下载
37+
### 编辑器扩展
38+
39+
- [Gitea的Visual Studio扩展](https://github.com/maikebing/Gitea.VisualStudio)[Visual Studio 扩展市场](https://marketplace.visualstudio.com/items?itemName=MysticBoy.GiteaExtensionforVisualStudio) 下载

Diff for: docs/content/doc/developers/api-usage.en-us.md

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ A new token can be generated with a `POST` request to
4848
Note that `/users/:name/tokens` is a special endpoint and requires you
4949
to authenticate using `BasicAuth` and a password, as follows:
5050

51-
5251
```sh
5352
$ curl -XPOST -H "Content-Type: application/json" -k -d '{"name":"test"}' -u username:password https://gitea.your.host/api/v1/users/<username>/tokens
5453
{"id":1,"name":"test","sha1":"9fcb1158165773dd010fca5f0cf7174316c3e37d","token_last_eight":"16c3e37d"}

Diff for: docs/content/doc/developers/guidelines-backend.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ menu:
2121

2222
## Background
2323

24-
Gitea uses Golang as the backend programming language. It uses many third-party packages and also write some itself.
25-
For example, Gitea uses [Chi](https://github.com/go-chi/chi) as basic web framework. [Xorm](https://xorm.io) is an ORM framework that is used to interact with the database.
24+
Gitea uses Golang as the backend programming language. It uses many third-party packages and also write some itself.
25+
For example, Gitea uses [Chi](https://github.com/go-chi/chi) as basic web framework. [Xorm](https://xorm.io) is an ORM framework that is used to interact with the database.
2626
So it's very important to manage these packages. Please take the below guidelines before you start to write backend code.
2727

2828
## Package Design Guideline
@@ -43,9 +43,9 @@ To maintain understandable code and avoid circular dependencies it is important
4343
- `modules/git`: Package to interactive with `Git` command line or Gogit package.
4444
- `public`: Compiled frontend files (javascript, images, css, etc.)
4545
- `routers`: Handling of server requests. As it uses other Gitea packages to serve the request, other packages (models, modules or services) must not depend on routers.
46-
- `routers/api` Contains routers for `/api/v1` aims to handle RESTful API requests.
47-
- `routers/install` Could only respond when system is in INSTALL mode (INSTALL_LOCK=false).
48-
- `routers/private` will only be invoked by internal sub commands, especially `serv` and `hooks`.
46+
- `routers/api` Contains routers for `/api/v1` aims to handle RESTful API requests.
47+
- `routers/install` Could only respond when system is in INSTALL mode (INSTALL_LOCK=false).
48+
- `routers/private` will only be invoked by internal sub commands, especially `serv` and `hooks`.
4949
- `routers/web` will handle HTTP requests from web browsers or Git SMART HTTP protocols.
5050
- `services`: Support functions for common routing operations or command executions. Uses `models` and `modules` to handle the requests.
5151
- `templates`: Golang templates for generating the html output.
@@ -61,7 +61,7 @@ From left to right, left packages could depend on right packages, but right pack
6161
**NOTICE**
6262

6363
Why do we need database transactions outside of `models`? And how?
64-
Some actions should allow for rollback when database record insertion/update/deletion failed.
64+
Some actions should allow for rollback when database record insertion/update/deletion failed.
6565
So services must be allowed to create a database transaction. Here is some example,
6666

6767
```go
@@ -84,7 +84,7 @@ func CreateXXXX() error {\
8484
}
8585
```
8686

87-
You should **not** use `db.GetEngine(ctx)` in `services` directly, but just write a function under `models/`.
87+
You should **not** use `db.GetEngine(ctx)` in `services` directly, but just write a function under `models/`.
8888
If the function will be used in the transaction, just let `context.Context` as the function's first parameter.
8989

9090
```go

Diff for: docs/content/doc/developers/guidelines-frontend.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Gitea uses [Less CSS](https://lesscss.org), [Fomantic-UI](https://fomantic-ui.co
2626
The HTML pages are rendered by [Go HTML Template](https://pkg.go.dev/html/template).
2727

2828
The source files can be found in the following directories:
29+
2930
* **Less styles:** `web_src/less/`
3031
* **JavaScript files:** `web_src/js/`
3132
* **Vue components:** `web_src/js/components/`
@@ -41,36 +42,37 @@ We recommend [Google HTML/CSS Style Guide](https://google.github.io/styleguide/h
4142
2. HTML ids and classes should use kebab-case.
4243
3. HTML ids and classes used in JavaScript should be unique for the whole project, and should contain 2-3 feature related keywords. We recommend to use the `js-` prefix for classes that are only used in JavaScript.
4344
4. jQuery events across different features could use their own namespaces if there are potential conflicts.
44-
5. CSS styling for classes provided by frameworks should not be overwritten. Always use new class-names with 2-3 feature related keywords to overwrite framework styles.
45+
5. CSS styling for classes provided by frameworks should not be overwritten. Always use new class-names with 2-3 feature related keywords to overwrite framework styles.
4546
6. The backend can pass complex data to the frontend by using `ctx.PageData["myModuleData"] = map[]{}`
4647
7. Simple pages and SEO-related pages use Go HTML Template render to generate static Fomantic-UI HTML output. Complex pages can use Vue2 (or Vue3 in future).
4748

48-
4949
### Framework Usage
5050

5151
Mixing different frameworks together is discouraged, it makes the code difficult to be maintained.
5252
A JavaScript module should follow one major framework and follow the framework's best practice.
5353

5454
Recommended implementations:
55+
5556
* Vue + Vanilla JS
5657
* Fomantic-UI (jQuery)
5758
* Vanilla JS
5859

5960
Discouraged implementations:
61+
6062
* Vue + Fomantic-UI (jQuery)
6163
* jQuery + Vanilla JS
6264

6365
To make UI consistent, Vue components can use Fomantic-UI CSS classes.
64-
Although mixing different frameworks is discouraged,
65-
it should also work if the mixing is necessary and the code is well-designed and maintainable.
66+
Although mixing different frameworks is discouraged,
67+
it should also work if the mixing is necessary and the code is well-designed and maintainable.
6668

6769
### `async` Functions
6870

69-
Only mark a function as `async` if and only if there are `await` calls
71+
Only mark a function as `async` if and only if there are `await` calls
7072
or `Promise` returns inside the function.
7173

7274
It's not recommended to use `async` event listeners, which may lead to problems.
73-
The reason is that the code after await is executed outside the event dispatch.
75+
The reason is that the code after await is executed outside the event dispatch.
7476
Reference: https://github.com/github/eslint-plugin-github/blob/main/docs/rules/async-preventdefault.md
7577

7678
If we want to call an `async` function in a non-async context,
@@ -88,10 +90,9 @@ However, there are still some special cases, so the current guideline is:
8890
* `$.data()` can be used to bind some non-string data to elements in rare cases, but it is highly discouraged.
8991

9092
* For new code:
91-
* `node.dataset` should not be used, use `node.getAttribute` instead.
93+
* `node.dataset` should not be used, use `node.getAttribute` instead.
9294
* never bind any user data to a DOM node, use a suitable design pattern to describe the relation between node and data.
9395

94-
9596
### Legacy Code
9697

9798
A lot of legacy code already existed before this document's written. It's recommended to refactor legacy code to follow the guidelines.

0 commit comments

Comments
 (0)