Skip to content

Commit fe21bc4

Browse files
authored
Add sphinx theme (#123)
1 parent 09c48a2 commit fe21bc4

27 files changed

+2115
-31
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@
1818
.idea/
1919
.DS_Store
2020
dist/
21+
*.egg-info/
22+
__pycache__/
23+
_build/
24+
sphinx_airflow_theme/sphinx_airflow_theme/static/_gen/

.pre-commit-config.yaml

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ repos:
3636
- --comment-style
3737
- "|#|"
3838
- --license-filepath
39-
- license-templates.txt
39+
- license-templates/LICENSE.txt
4040
- --fuzzy-match-generates-todo
4141
files: ^\.gitmodules$|^\.gitignore$|^\.gitignore$|^Dockerfile.*$
4242
- id: insert-license
@@ -46,7 +46,7 @@ repos:
4646
- --comment-style
4747
- "/**| *| */"
4848
- --license-filepath
49-
- license-templates.txt
49+
- license-templates/LICENSE.txt
5050
- --fuzzy-match-generates-todo
5151
- id: insert-license
5252
name: Add licence for all shell files
@@ -56,7 +56,7 @@ repos:
5656
- --comment-style
5757
- "|#|"
5858
- --license-filepath
59-
- license-templates.txt
59+
- license-templates/LICENSE.txt
6060
- --fuzzy-match-generates-todo
6161
- id: insert-license
6262
name: Add licence for all yaml files
@@ -65,7 +65,7 @@ repos:
6565
- --comment-style
6666
- "|#|"
6767
- --license-filepath
68-
- license-templates.txt
68+
- license-templates/LICENSE.txt
6969
- --fuzzy-match-generates-todo
7070
- id: insert-license
7171
name: Add licence for all TOML files
@@ -74,7 +74,7 @@ repos:
7474
- --comment-style
7575
- "|#|"
7676
- --license-filepath
77-
- license-templates.txt
77+
- license-templates/LICENSE.txt
7878
- --fuzzy-match-generates-todo
7979
- id: insert-license
8080
name: Add licence for all HTML files
@@ -83,9 +83,36 @@ repos:
8383
- --comment-style
8484
- "{{/*||*/}}"
8585
- --license-filepath
86-
- license-templates.txt
86+
- license-templates/LICENSE.txt
8787
- --fuzzy-match-generates-todo
8888
files: ^landing-pages/site/layouts/.+\.html$
89+
- id: insert-license
90+
name: Add licence for all Python files
91+
types: [python]
92+
args:
93+
- --comment-style
94+
- "|#|"
95+
- --license-filepath
96+
- license-templates/LICENSE.txt
97+
- --fuzzy-match-generates-todo
98+
- id: insert-license
99+
name: Add license for all rst files
100+
args:
101+
- --comment-style
102+
- "||"
103+
- --license-filepath
104+
- license-templates/LICENSE.rst
105+
- --fuzzy-match-generates-todo
106+
files: \.rst$
107+
- id: insert-license
108+
name: Add license for all JINJA template files
109+
files: ^sphinx_airflow_theme/.*\.html$
110+
args:
111+
- --comment-style
112+
- "{#||#}"
113+
- --license-filepath
114+
- license-templates/LICENSE.txt
115+
- --fuzzy-match-generates-todo
89116
- repo: local
90117
hooks:
91118
- id: shellcheck
@@ -110,22 +137,22 @@ repos:
110137
entry: ./site.sh lint-js
111138
language: system
112139
files: \.js$
113-
- repo: https://github.com/pre-commit/pre-commit-hooks
114-
rev: v2.3.0
115-
hooks:
116-
- id: check-executables-have-shebangs
117-
- id: check-json
118-
- id: check-merge-conflict
119-
- id: check-toml
120-
- id: check-yaml
121-
- id: detect-private-key
122-
- id: end-of-file-fixer
123-
- id: pretty-format-json
124-
args:
125-
- --indent=2
126-
- --autofix
127-
- --top-keys=name,version,description,repository,main,author,license,scripts
128-
- id: mixed-line-ending
129-
- id: requirements-txt-fixer
130-
- id: trailing-whitespace
131-
args: [--markdown-linebreak-ext=md]
140+
- repo: https://github.com/pre-commit/pre-commit-hooks
141+
rev: v2.3.0
142+
hooks:
143+
- id: check-executables-have-shebangs
144+
- id: check-json
145+
- id: check-merge-conflict
146+
- id: check-toml
147+
- id: check-yaml
148+
- id: detect-private-key
149+
- id: end-of-file-fixer
150+
- id: pretty-format-json
151+
args:
152+
- --indent=2
153+
- --autofix
154+
- --top-keys=name,version,description,repository,main,author,license,scripts
155+
- id: mixed-line-ending
156+
- id: requirements-txt-fixer
157+
- id: trailing-whitespace
158+
args: [--markdown-linebreak-ext=md]

landing-pages/site/assets/scss/_roadmap.scss

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,18 +227,17 @@
227227
li.current > a {
228228
border-left: solid 4px #017cee;
229229
color: #017cee;
230-
padding-left: 1.25em;
231230
}
232231

233-
li.toctree-l2 > a {
232+
li li > a {
234233
padding-left: 2.427em;
235234
}
236235

237-
li.toctree-l3 > a {
236+
li li li > a {
238237
padding-left: 4.045em;
239238
}
240239

241-
li.toctree-l4 > a {
240+
li li li li > a {
242241
padding-left: 5.663em;
243242
}
244243
}

landing-pages/src/docs-index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import "./js/navbarScroll";
21+
import "./js/drawer";
22+
import "./js/contentDrawer";
23+
import "./js/progressTracking";
24+
import "./js/rating";
25+
import "./js/makeTableResponsive";
26+
import "./js/tocTree";

landing-pages/src/js/tocTree.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
Array.from(document.querySelectorAll(".toctree ul")).forEach((listElement) => {
21+
const siblingsLinks = Array.from(listElement.parentNode.children).filter((d) => d.tagName === "A");
22+
siblingsLinks.forEach((linkElement) => {
23+
const expandElement = document.createElement("span");
24+
expandElement.classList.add("toctree-expand");
25+
linkElement.insertBefore(expandElement, linkElement.firstChild);
26+
});
27+
});

landing-pages/webpack.common.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ const AssetsPlugin = require("assets-webpack-plugin");
2525

2626
module.exports = {
2727
entry: {
28-
main: path.join(__dirname, "src", "index.js")
28+
main: path.join(__dirname, "src", "index.js"),
29+
docs: path.join(__dirname, "src", "docs-index.js")
2930
},
3031

3132
output: {

license-templates/LICENSE.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.. Licensed to the Apache Software Foundation (ASF) under one
2+
or more contributor license agreements. See the NOTICE file
3+
distributed with this work for additional information
4+
regarding copyright ownership. The ASF licenses this file
5+
to you under the Apache License, Version 2.0 (the
6+
"License"); you may not use this file except in compliance
7+
with the License. You may obtain a copy of the License at
8+
9+
.. http://www.apache.org/licenses/LICENSE-2.0
10+
11+
.. Unless required by applicable law or agreed to in writing,
12+
software distributed under the License is distributed on an
13+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
KIND, either express or implied. See the License for the
15+
specific language governing permissions and limitations
16+
under the License.
File renamed without changes.

site.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ These are ${0} commands used in various situations:
3636
cleanup Delete the virtual environment in Docker
3737
build-image Build a Docker image with a environment
3838
install-node-deps Download all the Node dependencies
39-
preview Starts the web server
39+
preview-site Starts the web server with preview of the website
40+
preview-docs Starts the web server with preview of the Sphinx theme
41+
prepare-theme Prepares and copies files needed for the proper functioning of the sphinx theme.
4042
build-landing-pages Builds a landing pages
4143
build-site Builds a website with documentation
4244
check-site-links Checks if the links are correct in the website
@@ -222,6 +224,7 @@ function build_site {
222224
EOF
223225
}
224226

227+
225228
function cleanup_environment {
226229
container_status="$(docker inspect "${CONTAINER_NAME}" --format '{{.State.Status}}')"
227230
echo "Current container status: ${container_status}"
@@ -241,6 +244,16 @@ function cleanup_environment {
241244
fi
242245
}
243246

247+
function prepare_theme {
248+
SITE_DIST="landing-pages/dist"
249+
THEME_GEN="sphinx_airflow_theme/sphinx_airflow_theme/static/_gen"
250+
mkdir -p "${THEME_GEN}/css" "${THEME_GEN}/js"
251+
cp ${SITE_DIST}/docs.*.js "${THEME_GEN}/js/docs.js"
252+
cp ${SITE_DIST}/scss/main.min.*.css "${THEME_GEN}/css/main.min.css"
253+
cp ${SITE_DIST}/scss/main-custom.min.*.css "${THEME_GEN}/css/main-custom.min.css"
254+
echo "Successful copied required files"
255+
}
256+
244257
if [[ "$#" -eq 0 ]]; then
245258
echo "You must provide at least one command."
246259
echo
@@ -289,6 +302,9 @@ elif [[ "${CMD}" == "check-site-links" ]]; then
289302
ensure_node_module_exists
290303
ensure_that_website_is_build
291304
run_command "/opt/site/landing-pages/" ./check-links.sh
305+
elif [[ "${CMD}" == "prepare-theme" ]]; then
306+
ensure_that_website_is_build
307+
prepare_theme
292308
elif [[ "${CMD}" == "lint-js" ]]; then
293309
ensure_node_module_exists
294310
if [[ "$#" -eq 0 ]]; then

sphinx_airflow_theme/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
# Sphinx theme for Airflow

0 commit comments

Comments
 (0)