Skip to content

Commit 956e773

Browse files
authored
Merge pull request #123 from mapillary/Rubix982/Docusaurus
[Documentation] `Docusaurus` instantiation
2 parents 0f0a627 + 3109daa commit 956e773

Some content is hidden

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

59 files changed

+16906
-30
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,7 @@ dmypy.json
141141
cython_debug/
142142

143143
# Testing
144-
tests/helper/data/*.geojson
144+
tests/helper/data/*.geojson
145+
146+
# Sphinx documentation generation
147+
sphinx-docs/

Makefile

Lines changed: 93 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,101 @@
11
# Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com)
22

33
define PYTHON_SCRIPT
4+
45
import os
56
import sys
7+
68
sys.path.insert(0, os.path.abspath('../'))
79

8-
def skip(app, what, name, obj,would_skip, options):
9-
if name in ( '__init__',):
10-
return False
11-
return would_skip
1210

13-
def setup(app):
14-
app.connect('autodoc-skip-member', skip)
15-
extensions.append('sphinx_autodoc_typehints')
11+
def skip(app, what, name, obj, would_skip, options):
12+
'''Skip'''
13+
14+
extensions.append('sphinx_autodoc_typehints')
15+
16+
if name in ('__init__',):
17+
return False
18+
return would_skip
19+
20+
21+
def setup(app):
22+
'''Setup App'''
23+
24+
app.connect('autodoc-skip-member', skip)
1625
endef
1726

27+
# SETUP
28+
29+
# # Setup all
30+
setup: setup-prod setup-dev
31+
32+
# # Install needed dependencies
33+
setup-prod:
34+
python -m pip install --upgrade pip
35+
pip install pipenv
36+
pipenv install
37+
38+
# # Install developer dependencies
39+
setup-dev:
40+
python -m pip install --upgrade pip
41+
pip install pipenv
42+
pipenv install --dev
43+
44+
# PACKAGE BUILD
45+
46+
# # Build the package
47+
build:
48+
# Builds the package distributions
49+
python3 setup.py sdist bdist_wheel --universal
50+
51+
local-install:
52+
# Locally install mapillary - DO THIS ONLY AFTER RUNNING `make build`
53+
pip3 install -e .
54+
55+
# CODE QUALITY
56+
57+
# # Styling related
1858
style: format lint
1959

60+
# # # Formatting
2061
format:
21-
black src/mapillary
62+
@ black src/mapillary
2263

64+
# # # Linting
2365
lint:
24-
# stop the build if there are Python syntax errors or undefined names
25-
flake8 src/mapillary --count --select=E9,F63,F7,F82 --show-source --statistics
66+
@ # stop the build if there are Python syntax errors or undefined names
67+
@ flake8 src/mapillary --count --select=E9,F63,F7,F82 --show-source --statistics
68+
69+
@ # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
70+
@ flake8 src/mapillary --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
71+
72+
# DOCUMENTATION
2673

27-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
28-
flake8 src/mapillary --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
74+
# # For generating the latest developer documentation from src/mapillary
75+
# # and serving them locally with Docusaurus
76+
docs-gen: docs-sphinx docs-py docs-start
2977

30-
sphinx-docs:
78+
# # # Sphinx Documentation Generation
79+
docs-sphinx:
3180
sphinx-apidoc -o sphinx-docs ./src/ sphinx-apidoc --full -A 'Mapillary'; cd sphinx-docs; echo "$$PYTHON_SCRIPT" >> conf.py; make markdown;
3281

33-
sphinx-docs-clean:
34-
rm -rf sphinx-docs/
82+
# # # Python Script for moving markdown from sphinx -> docusaurus
83+
docs-py:
84+
python3 scripts/documentation.py
85+
86+
# # # Serve the newly generated documentation
87+
docs-start:
88+
cd docs; npm run start;
3589

36-
docs: docs-build docs-deploy
90+
# # For pushing the docs to the gh-pages branch
91+
docs-push: docs-build docs-deploy
3792

93+
# # # Building the static pages
94+
docs-build:
95+
# Building the documentation
96+
cd docs; npm run build;
97+
98+
# # # Deploying the documentation to gh-pages
3899
docs-deploy:
39100
# Deploying the documentation
40101
# Deploying requires GIT_USER's password and write access to the repository
@@ -44,14 +105,25 @@ docs-deploy:
44105
# https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/
45106
cd docs; GIT_USER=Rubix982 yarn deploy;
46107

47-
docs-build:
48-
# Building the documentation
49-
cd docs; npm run build;
108+
# CLEANING
109+
110+
# # Removing temporary created artifacts
111+
clean: sphinx-docs-clean docs-clean build-clean
112+
113+
# # # Remove Sphinx Documentation
114+
sphinx-docs-clean:
115+
rm -rf sphinx-docs/
50116

117+
# # # Remove latest build of docs
51118
docs-clean:
52119
rm -rf docs/build
53120

121+
# # # Remove latest sr/mapillary build
122+
build-clean:
123+
rm -rf build/ dist/
124+
125+
# TESTING
126+
127+
# # Execute pytest on tests/
54128
test:
55129
@ pytest --log-cli-level=20
56-
57-
clean: sphinx-docs-clean docs-clean

docs/.eslintrc.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
*/
9+
10+
const OFF = 0;
11+
const WARNING = 1;
12+
const ERROR = 2;
13+
14+
module.exports = {
15+
root: true,
16+
env: {
17+
browser: true,
18+
commonjs: true,
19+
jest: true,
20+
node: true,
21+
},
22+
parser: '@babel/eslint-parser',
23+
parserOptions: {
24+
allowImportExportEverywhere: true,
25+
},
26+
extends: ['airbnb', 'prettier', 'prettier/react'],
27+
plugins: ['react-hooks', 'header'],
28+
rules: {
29+
// Ignore certain webpack alias because it can't be resolved
30+
'import/no-unresolved': [
31+
ERROR,
32+
{ignore: ['^@theme', '^@docusaurus', '^@generated']},
33+
],
34+
'import/extensions': OFF,
35+
'header/header': [
36+
ERROR,
37+
'block',
38+
39+
[
40+
'*',
41+
' * Copyright (c) Facebook, Inc. and its affiliates.',
42+
' *',
43+
' * This source code is licensed under the MIT license found in the',
44+
' * LICENSE file in the root directory of this source tree.',
45+
' *',
46+
// Unfortunately eslint-plugin-header doesn't support optional lines.
47+
// If you want to enforce your website JS files to have @flow or @format,
48+
// modify these lines accordingly.
49+
{
50+
pattern: '.* @format',
51+
},
52+
' ',
53+
],
54+
],
55+
'react/jsx-closing-bracket-location': OFF, // Conflicts with Prettier.
56+
'react/jsx-filename-extension': OFF,
57+
'react-hooks/rules-of-hooks': ERROR,
58+
'react/prop-types': OFF, // PropTypes aren't used much these days.
59+
},
60+
};

docs/.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Dependencies
2+
/node_modules
3+
4+
# Production
5+
/build
6+
7+
# Generated files
8+
.docusaurus
9+
.cache-loader
10+
11+
# Misc
12+
.DS_Store
13+
.env.local
14+
.env.development.local
15+
.env.test.local
16+
.env.production.local
17+
18+
npm-debug.log*
19+
yarn-debug.log*
20+
yarn-error.log*
21+
22+
# ESLint
23+
.eslintcache

docs/.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
build
3+
.docusaurus

docs/.prettierrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"arrowParens": "always",
3+
"bracketSpacing": false,
4+
"jsxBracketSameLine": true,
5+
"printWidth": 80,
6+
"proseWrap": "never",
7+
"singleQuote": true,
8+
"trailingComma": "all"
9+
}

docs/.stylelintrc.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
module.exports = {
9+
plugins: ['stylelint-copyright'],
10+
rules: {
11+
'docusaurus/copyright-header': true,
12+
},
13+
};

docs/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Website
2+
3+
This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator.
4+
5+
### Installation
6+
7+
```
8+
$ yarn
9+
```
10+
11+
### Local Development
12+
13+
```
14+
$ yarn start
15+
```
16+
17+
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
18+
19+
### Build
20+
21+
```
22+
$ yarn build
23+
```
24+
25+
This command generates static content into the `build` directory and can be served using any static contents hosting service.
26+
27+
### Deployment
28+
29+
```
30+
$ GIT_USER=<Your GitHub username> USE_SSH=true yarn deploy
31+
```
32+
33+
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
34+
35+
### Continuous Integration
36+
37+
Some common defaults for linting/formatting have been set for you. If you integrate your project with an open source Continuous Integration system (e.g. Travis CI, CircleCI), you may check for issues using the following command.
38+
39+
```
40+
$ yarn ci
41+
```

docs/babel.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
*/
9+
10+
module.exports = {
11+
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
12+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
slug: first-blog-post
3+
title: First Blog Post
4+
authors:
5+
name: Gao Wei
6+
title: Docusaurus Core Team
7+
url: https://github.com/wgao19
8+
image_url: https://github.com/wgao19.png
9+
tags: [hola, docusaurus]
10+
---
11+
12+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

0 commit comments

Comments
 (0)