Skip to content

Commit

Permalink
add mkdocs
Browse files Browse the repository at this point in the history
Signed-off-by: weiwee <[email protected]>
  • Loading branch information
sagewe committed Nov 6, 2021
1 parent dd1b7ca commit 28da6ee
Show file tree
Hide file tree
Showing 20 changed files with 1,330 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

mkdocs:
configuration: mkdocs.yml
fail_on_warning: false

formats: all

python:
version: 3.7
install:
- requirements: doc/mkdocs/requirements.txt
4 changes: 4 additions & 0 deletions doc/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
template: overrides/home.html
title: Secure, Privacy-preserving Machine Learning
---
4 changes: 4 additions & 0 deletions doc/index.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
template: overrides/home.zh.html
title: 安全,隐私保护的机器学习
---
98 changes: 98 additions & 0 deletions doc/mkdocs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Build

## use docker

At repo root, execute

```sh
docker run --rm -it -p 8000:8000 -v ${PWD}:/docs sagewei0/mkdocs
```

to serve docs in http://localhost:8000

or

```sh
docker run --rm -it -p 8000:8000 -v ${PWD}:/docs sagewei0/mkdocs build
```

to build docs to `site` folder.

## manually

[`mkdocs-material`](https://pypi.org/project/mkdocs-material/) and servel plugins are needed to build this docs

Fisrt, create an python virtual environment

```sh
python3 -m venv "fatedocs"
source fatedocs/bin/activate
pip install -U pip
```
And then install requirements

```sh
pip install -r doc/mkdocs/requirements.txt
```

Now, use

```sh
mkdocs serve
```

at repo root to serve docs or

use

```sh
mkdocs build
```

at repo root to build docs to folder `site`


# Develop guide

We use [mkdocs-material](https://squidfunk.github.io/mkdocs-material/) to build our docs.
Servel markdown extensions are really useful to write pretty documents such as
[admonitions](https://squidfunk.github.io/mkdocs-material/reference/admonitions/) and
[content-tabs](https://squidfunk.github.io/mkdocs-material/reference/content-tabs/).

Servel plugins are introdused to makes mkdocs-material much powerful:


- [mkdocstrings](https://mkdocstrings.github.io/usage/)
automatic documentation from sources code. We mostly use this to automatic generate
`params api` for `federatedml`.

- [awesome-pages](https://github.com/lukasgeiter/mkdocs-awesome-pages-plugin)
for powerful nav rule

- [i18n](https://ultrabug.github.io/mkdocs-static-i18n/)
for multi-languege support

- [mkdocs-jupyter](https://github.com/danielfrg/mkdocs-jupyter)
for jupyter format support

- [mkdocs-simple-hooks](https://github.com/aklajnert/mkdocs-simple-hooks)
for simple plugin-in

## macro extension

### include examples

```
{% include-examples "<name>" %}
```
extract all components's examples(pipeline, dsl v1, dsl v2) from `examples` folder

### include example

```
{% include-example "???" %}
```

extract source code `???` from repo.


1 change: 1 addition & 0 deletions doc/mkdocs/assets/animations/ml.json

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions doc/mkdocs/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* Indentation. */
div.doc-contents:not(.first) {
padding-left: 25px;
border-left: 4px solid rgba(230, 230, 230);
margin-bottom: 80px;
}

/* Don't capitalize names. */
h5.doc-heading {
text-transform: none !important;
}

/* Don't use vertical space on hidden ToC entries. */
h6.hidden-toc {
margin: 0 !important;
position: relative;
top: -70px;
}

h6.hidden-toc::before {
margin-top: 0 !important;
padding-top: 0 !important;
}

/* Don't show permalink of hidden ToC entries. */
h6.hidden-toc a.headerlink {
display: none;
}

/* Avoid breaking parameters name, etc. in table cells. */
td code {
word-break: normal !important;
}

/* For pieces of Markdown rendered in table cells. */
td p {
margin-top: 0 !important;
margin-bottom: 0 !important;
}
34 changes: 34 additions & 0 deletions doc/mkdocs/css/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* Remove default title on the page */
.md-content__inner h1:first-child {
display: none;
}

/* Adjust to 2px to align with the title */
.md-logo {
padding-top: 6px;
}

.btn {
border: none;
padding: 14px 28px;
cursor: pointer;
display: inline-block;

background: #009688;
color: white;
}

.btn:hover {
background: #00bfa5;
color: white;
}

.center {
display: block;
margin-left: auto;
margin-right: auto;
}

.text-center {
text-align: center;
}
144 changes: 144 additions & 0 deletions doc/mkdocs/css/landing.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
.tx-container {
background:
linear-gradient(to bottom, var(--md-primary-fg-color), #2196f3 100%, var(--md-default-bg-color) 100%)
}

[data-md-color-scheme=slate] .tx-container {
background:
linear-gradient(to bottom, var(--md-primary-fg-color), #2196f3 100%, var(--md-default-bg-color) 100%)
}

.tx-landing {
margin: 0 .8rem;
color: var(--md-primary-bg-color)
}

.tx-landing h1 {
margin-bottom: 1rem;
color: currentColor;
font-weight: 700
}

@media screen and (max-width: 30em) {
.tx-landing h1 {
font-size: 1.4rem
}
}

.tx-landing__content p a {
color: inherit;
text-decoration: underline;
}

.tx-landing__testimonials {
width: 100%;
text-align: center;
}

.tx-landing__content p a:hover {
color: darkblue;
text-decoration: underline;
}

.tx-landing__logos {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
}

.tx-landing__logos img {
height: 8vh;
max-height: 81px; /* max height of images */
width: auto;
margin: 2vh;
vertical-align: middle;
}

.tx-landing__quotes {
padding-bottom: 5em;
text-align: center;
}

@media screen and (min-width: 60em) {
.tx-landing__quotes {
margin: 1em 5em;
}
}

.tx-landing__quotes figure {
margin: 2em auto 2em auto;
}

.tx-landing__quote {
display: flex;
border-radius: 1em;
padding: 1em 1em 0 1em;
background: var(--md-primary-fg-color);
}

.tx-landing__quote blockquote {
border: 0;
color: #fff;
}

.tx-landing__quote a img {
height: 6vh;
max-height: 81px; /* max height of images */
display: block;
margin-left: auto;
margin-right: auto;
}

@media screen and (min-width: 60em) {
.tx-container {
padding-bottom: 14vw
}

.tx-landing {
display: flex;
align-items: stretch
}

.tx-landing__content {
max-width: 24rem;
margin-top: 3.5rem;
}

.tx-landing__image {
order: 1;
width: 38rem;
transform: translateX(4rem)
}
}

@media screen and (min-width: 77em) {
.tx-landing__image {
transform: translateX(8rem)
}
}

.tx-landing .md-button {
margin-top: .5rem;
margin-right: .5rem;
color: var(--md-primary-bg-color)
}

.tx-landing .md-button:hover, .tx-landing .md-button:focus {
color: var(--md-default-bg-color);
background-color: #8bc34a;
border-color: #8bc34a
}

.md-typeset lottie-player {
max-width: 100%;
height: auto;
}

.md-announce a {
color: var(--md-primary-bg-color);
}

.md-banner a {
color: var(--md-primary-bg-color);
}
Loading

0 comments on commit 28da6ee

Please sign in to comment.