2020-07-19 22:23:26 +02:00
|
|
|
|
---
|
|
|
|
|
template: overrides/main.html
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# Adding a git repository
|
|
|
|
|
|
2020-07-21 13:33:44 +02:00
|
|
|
|
If your documentation is related to source code, Material for MkDocs provides
|
|
|
|
|
the ability to display information to the project's repository as part of the
|
2020-07-26 14:46:09 +02:00
|
|
|
|
static site, including statistics like stars and forks. Furthermore, individual
|
2020-07-21 13:33:44 +02:00
|
|
|
|
documents can be linked to specific source files.
|
2020-07-19 22:23:26 +02:00
|
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
|
2020-07-21 13:33:44 +02:00
|
|
|
|
In order to display a link to the repository of your project as part of your
|
|
|
|
|
documentation, set [`repo_url`][1] in `mkdocs.yml` to the public URL of your
|
|
|
|
|
repository, e.g.:
|
2020-07-19 22:23:26 +02:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
repo_url: https://github.com/squidfunk/mkdocs-material
|
|
|
|
|
```
|
|
|
|
|
|
2020-07-21 13:33:44 +02:00
|
|
|
|
The link to the repository will be rendered next to the search bar on big
|
2020-07-19 22:23:26 +02:00
|
|
|
|
screens and as part of the main navigation drawer on smaller screen sizes.
|
2020-07-21 13:33:44 +02:00
|
|
|
|
Additionally, for GitHub and GitLab, the number of stars and forks is
|
|
|
|
|
automatically requested and rendered for _public repositories_.
|
|
|
|
|
|
|
|
|
|
[1]: https://www.mkdocs.org/user-guide/configuration/#repo_url
|
|
|
|
|
|
|
|
|
|
### Repository name
|
|
|
|
|
|
|
|
|
|
[:octicons-file-code-24: Source][2] · :octicons-milestone-24: Default:
|
|
|
|
|
_automatically set to_ `GitHub`, `GitLab` _or_ `Bitbucket`
|
|
|
|
|
|
|
|
|
|
MkDocs will infer the source provider by examining the URL and try to set the
|
|
|
|
|
_repository name_ automatically. If you wish to customize the name, set
|
|
|
|
|
[`repo_name`][3] in `mkdocs.yml`:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
repo_name: squidfunk/mkdocs-material
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
[2]: https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/source.html
|
2020-07-23 15:34:43 +02:00
|
|
|
|
[3]: https://www.mkdocs.org/user-guide/configuration/#repo_name
|
2020-07-21 13:33:44 +02:00
|
|
|
|
|
|
|
|
|
### Repository icon
|
|
|
|
|
|
2020-07-23 15:34:43 +02:00
|
|
|
|
[:octicons-file-code-24: Source][2] · :octicons-milestone-24: Default:
|
2020-07-21 13:33:44 +02:00
|
|
|
|
`fontawesome/brands/git-alt`
|
|
|
|
|
|
|
|
|
|
While the default _repository icon_ is a generic git icon, it can be set to
|
|
|
|
|
[any icon bundled with the theme][4] by referencing a valid icon path in
|
|
|
|
|
`mkdocs.yml`:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
theme:
|
|
|
|
|
icon:
|
|
|
|
|
repo: fontawesome/brands/git-alt
|
|
|
|
|
```
|
|
|
|
|
|
2020-07-21 16:01:22 +02:00
|
|
|
|
Some popular choices:
|
|
|
|
|
|
2020-11-15 22:25:11 +01:00
|
|
|
|
- :fontawesome-brands-git: – `fontawesome/brands/git`
|
|
|
|
|
- :fontawesome-brands-git-alt: – `fontawesome/brands/git-alt`
|
|
|
|
|
- :fontawesome-brands-git-square: – `fontawesome/brands/git-square`
|
|
|
|
|
- :fontawesome-brands-github: – `fontawesome/brands/github`
|
|
|
|
|
- :fontawesome-brands-github-alt: – `fontawesome/brands/github-alt`
|
|
|
|
|
- :fontawesome-brands-github-square: – `fontawesome/brands/github-square`
|
|
|
|
|
- :fontawesome-brands-gitlab: – `fontawesome/brands/gitlab`
|
|
|
|
|
- :fontawesome-brands-gitkraken: – `fontawesome/brands/gitkraken`
|
|
|
|
|
- :fontawesome-brands-bitbucket: – `fontawesome/brands/bitbucket`
|
|
|
|
|
- :fontawesome-solid-trash: – `fontawesome/solid/trash`
|
2020-07-21 13:33:44 +02:00
|
|
|
|
|
|
|
|
|
[4]: https://github.com/squidfunk/mkdocs-material/tree/master/material/.icons
|
|
|
|
|
|
2021-01-17 12:42:46 +01:00
|
|
|
|
### Latest release
|
|
|
|
|
|
|
|
|
|
[:octicons-file-code-24: Source][5] ·
|
2021-03-13 14:30:29 +01:00
|
|
|
|
[:octicons-heart-fill-24:{ .mdx-heart } Insiders only][5]{ .mdx-insiders }
|
2021-01-17 12:42:46 +01:00
|
|
|
|
|
|
|
|
|
The visual appearance of the repository link has been improved as part of
|
|
|
|
|
[Insiders][5], and will now automatically include the latest release tag which
|
|
|
|
|
is not marked as a draft or pre-release:
|
|
|
|
|
|
|
|
|
|
<figure markdown="1">
|
|
|
|
|
|
|
|
|
|
[![Search suggestions][6]][6]
|
|
|
|
|
|
|
|
|
|
<figcaption markdown="1">
|
|
|
|
|
|
|
|
|
|
A demo is worth a thousand words — check it out at
|
|
|
|
|
[squidfunk.github.io/mkdocs-material-insiders][7]
|
|
|
|
|
|
|
|
|
|
</figcaption>
|
|
|
|
|
</figure>
|
|
|
|
|
|
2021-03-21 14:04:29 +01:00
|
|
|
|
[5]: ../insiders/index.md
|
2021-01-17 12:42:46 +01:00
|
|
|
|
[6]: ../assets/screenshots/repository.png
|
|
|
|
|
[7]: https://squidfunk.github.io/mkdocs-material-insiders/setup/adding-a-git-repository/
|
|
|
|
|
|
2020-07-21 13:33:44 +02:00
|
|
|
|
### Edit button
|
|
|
|
|
|
2021-01-17 12:42:46 +01:00
|
|
|
|
[:octicons-file-code-24: Source][8] · :octicons-milestone-24: Default:
|
2020-07-21 13:33:44 +02:00
|
|
|
|
_automatically set_
|
|
|
|
|
|
2021-01-17 12:42:46 +01:00
|
|
|
|
If the repository URL points to a [GitHub][9], [GitLab][10] or [Bitbucket][11]
|
2020-07-21 13:33:44 +02:00
|
|
|
|
repository, an _edit button_ is displayed at the top of each document. This
|
2021-01-17 12:42:46 +01:00
|
|
|
|
behavior can be changed by setting [`edit_uri`][12] in `mkdocs.yml`:
|
2020-07-21 13:33:44 +02:00
|
|
|
|
|
|
|
|
|
=== "Customize edit path"
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
edit_uri: edit/master/docs/
|
|
|
|
|
```
|
2020-07-19 22:23:26 +02:00
|
|
|
|
|
2020-07-21 13:33:44 +02:00
|
|
|
|
=== "Hide edit button"
|
2020-07-19 22:23:26 +02:00
|
|
|
|
|
2020-07-21 13:33:44 +02:00
|
|
|
|
``` yaml
|
|
|
|
|
edit_uri: ""
|
|
|
|
|
```
|
2020-07-19 22:23:26 +02:00
|
|
|
|
|
2021-01-17 12:42:46 +01:00
|
|
|
|
[8]: https://github.com/squidfunk/mkdocs-material/blob/master/src/base.html
|
|
|
|
|
[9]: https://github.com/
|
|
|
|
|
[10]: https://about.gitlab.com/
|
|
|
|
|
[11]: https://bitbucket.org/
|
|
|
|
|
[12]: https://www.mkdocs.org/user-guide/configuration/#edit_uri
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
|
|
|
|
### Revision date
|
|
|
|
|
|
2021-01-17 12:42:46 +01:00
|
|
|
|
[:octicons-file-code-24: Source][13] ·
|
|
|
|
|
[:octicons-cpu-24: Plugin][14]
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
2021-01-17 12:42:46 +01:00
|
|
|
|
The [git-revision-date][13] plugin adds support for displaying the date a
|
2020-08-01 20:21:42 +02:00
|
|
|
|
document was _last updated_ at the bottom of each page. It can be installed
|
|
|
|
|
with `pip`:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
pip install mkdocs-git-revision-date-plugin
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Then, add the following to `mkdocs.yml`:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
plugins:
|
|
|
|
|
- git-revision-date
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The following options are supported:
|
|
|
|
|
|
2021-03-13 14:30:29 +01:00
|
|
|
|
`enabled_if_env`{ #enabled_if_env }
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
|
|
|
|
: :octicons-milestone-24: Default: _none_ – This option defines whether the
|
|
|
|
|
date is actually extracted from git, which makes it possible to disable
|
|
|
|
|
extraction for cases when the repository is not available:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
plugins:
|
|
|
|
|
- git-revision-date:
|
|
|
|
|
enabled_if_env: CI
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
_Material for MkDocs doesn't provide official support for the other options of
|
2021-03-21 17:14:32 +01:00
|
|
|
|
this plugin, so they may be supported but might yield unexpected results.
|
|
|
|
|
Use them at your own risk._
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
2021-01-17 12:42:46 +01:00
|
|
|
|
[13]: https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/source-date.html
|
|
|
|
|
[14]: https://github.com/zhaoterryy/mkdocs-git-revision-date-plugin
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
|
|
|
|
### Revision date, localized
|
|
|
|
|
|
2021-01-17 12:42:46 +01:00
|
|
|
|
[:octicons-file-code-24: Source][13] ·
|
|
|
|
|
[:octicons-cpu-24: Plugin][15]
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
2021-01-17 12:42:46 +01:00
|
|
|
|
Similarly, the [git-revision-date-localized][15] plugin adds support for adding
|
2020-08-01 20:21:42 +02:00
|
|
|
|
a localized _last updated_ date at the bottom of each page. It can be installed
|
|
|
|
|
with `pip`:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
pip install mkdocs-git-revision-date-localized-plugin
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Then, add the following to `mkdocs.yml`:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
plugins:
|
|
|
|
|
- git-revision-date-localized
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The following options are supported:
|
|
|
|
|
|
2021-03-13 14:30:29 +01:00
|
|
|
|
`type`{ #type }
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
|
|
|
|
: :octicons-milestone-24: Default: `date` – This option allows to change the
|
|
|
|
|
format of the date to be displayed. Valid values are `date`, `datetime`,
|
|
|
|
|
`iso_date`, `iso_datetime` and `timeago`:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
plugins:
|
|
|
|
|
- git-revision-date-localized:
|
|
|
|
|
type: date
|
|
|
|
|
```
|
|
|
|
|
|
2021-03-13 14:30:29 +01:00
|
|
|
|
`fallback_to_build_date`{ #fallback_to_build_date }
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
|
|
|
|
: :octicons-milestone-24: Default: `false` – This option specifies whether
|
|
|
|
|
the time when `mkdocs build` was executed should be used as a fallback when
|
|
|
|
|
the git repository is not available:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
plugins:
|
|
|
|
|
- git-revision-date-localized:
|
|
|
|
|
fallback_to_build_date: true
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
_Material for MkDocs doesn't provide official support for the other options of
|
2021-03-21 17:14:32 +01:00
|
|
|
|
this plugin, so they may be supported but might yield unexpected results.
|
|
|
|
|
Use them at your own risk._
|
2020-08-01 20:21:42 +02:00
|
|
|
|
|
2021-01-17 12:42:46 +01:00
|
|
|
|
[15]: https://github.com/timvink/mkdocs-git-revision-date-localized-plugin
|