Skip to content

Commit

Permalink
Add sphinx theme (apache#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
mik-laj authored Nov 8, 2019
1 parent af462cf commit 91f760c
Show file tree
Hide file tree
Showing 27 changed files with 2,115 additions and 31 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@
.idea/
.DS_Store
dist/
*.egg-info/
__pycache__/
_build/
sphinx_airflow_theme/sphinx_airflow_theme/static/_gen/
77 changes: 52 additions & 25 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ repos:
- --comment-style
- "|#|"
- --license-filepath
- license-templates.txt
- license-templates/LICENSE.txt
- --fuzzy-match-generates-todo
files: ^\.gitmodules$|^\.gitignore$|^\.gitignore$|^Dockerfile.*$
- id: insert-license
Expand All @@ -46,7 +46,7 @@ repos:
- --comment-style
- "/**| *| */"
- --license-filepath
- license-templates.txt
- license-templates/LICENSE.txt
- --fuzzy-match-generates-todo
- id: insert-license
name: Add licence for all shell files
Expand All @@ -56,7 +56,7 @@ repos:
- --comment-style
- "|#|"
- --license-filepath
- license-templates.txt
- license-templates/LICENSE.txt
- --fuzzy-match-generates-todo
- id: insert-license
name: Add licence for all yaml files
Expand All @@ -65,7 +65,7 @@ repos:
- --comment-style
- "|#|"
- --license-filepath
- license-templates.txt
- license-templates/LICENSE.txt
- --fuzzy-match-generates-todo
- id: insert-license
name: Add licence for all TOML files
Expand All @@ -74,7 +74,7 @@ repos:
- --comment-style
- "|#|"
- --license-filepath
- license-templates.txt
- license-templates/LICENSE.txt
- --fuzzy-match-generates-todo
- id: insert-license
name: Add licence for all HTML files
Expand All @@ -83,9 +83,36 @@ repos:
- --comment-style
- "{{/*||*/}}"
- --license-filepath
- license-templates.txt
- license-templates/LICENSE.txt
- --fuzzy-match-generates-todo
files: ^landing-pages/site/layouts/.+\.html$
- id: insert-license
name: Add licence for all Python files
types: [python]
args:
- --comment-style
- "|#|"
- --license-filepath
- license-templates/LICENSE.txt
- --fuzzy-match-generates-todo
- id: insert-license
name: Add license for all rst files
args:
- --comment-style
- "||"
- --license-filepath
- license-templates/LICENSE.rst
- --fuzzy-match-generates-todo
files: \.rst$
- id: insert-license
name: Add license for all JINJA template files
files: ^sphinx_airflow_theme/.*\.html$
args:
- --comment-style
- "{#||#}"
- --license-filepath
- license-templates/LICENSE.txt
- --fuzzy-match-generates-todo
- repo: local
hooks:
- id: shellcheck
Expand All @@ -110,22 +137,22 @@ repos:
entry: ./site.sh lint-js
language: system
files: \.js$
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
- id: pretty-format-json
args:
- --indent=2
- --autofix
- --top-keys=name,version,description,repository,main,author,license,scripts
- id: mixed-line-ending
- id: requirements-txt-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
- id: pretty-format-json
args:
- --indent=2
- --autofix
- --top-keys=name,version,description,repository,main,author,license,scripts
- id: mixed-line-ending
- id: requirements-txt-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
7 changes: 3 additions & 4 deletions landing-pages/site/assets/scss/_roadmap.scss
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,17 @@
li.current > a {
border-left: solid 4px #017cee;
color: #017cee;
padding-left: 1.25em;
}

li.toctree-l2 > a {
li li > a {
padding-left: 2.427em;
}

li.toctree-l3 > a {
li li li > a {
padding-left: 4.045em;
}

li.toctree-l4 > a {
li li li li > a {
padding-left: 5.663em;
}
}
Expand Down
26 changes: 26 additions & 0 deletions landing-pages/src/docs-index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import "./js/navbarScroll";
import "./js/drawer";
import "./js/contentDrawer";
import "./js/progressTracking";
import "./js/rating";
import "./js/makeTableResponsive";
import "./js/tocTree";
27 changes: 27 additions & 0 deletions landing-pages/src/js/tocTree.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

Array.from(document.querySelectorAll(".toctree ul")).forEach((listElement) => {
const siblingsLinks = Array.from(listElement.parentNode.children).filter((d) => d.tagName === "A");
siblingsLinks.forEach((linkElement) => {
const expandElement = document.createElement("span");
expandElement.classList.add("toctree-expand");
linkElement.insertBefore(expandElement, linkElement.firstChild);
});
});
3 changes: 2 additions & 1 deletion landing-pages/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const AssetsPlugin = require("assets-webpack-plugin");

module.exports = {
entry: {
main: path.join(__dirname, "src", "index.js")
main: path.join(__dirname, "src", "index.js"),
docs: path.join(__dirname, "src", "docs-index.js")
},

output: {
Expand Down
16 changes: 16 additions & 0 deletions license-templates/LICENSE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.. Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
.. http://www.apache.org/licenses/LICENSE-2.0
.. Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
File renamed without changes.
18 changes: 17 additions & 1 deletion site.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ These are ${0} commands used in various situations:
cleanup Delete the virtual environment in Docker
build-image Build a Docker image with a environment
install-node-deps Download all the Node dependencies
preview Starts the web server
preview-site Starts the web server with preview of the website
preview-docs Starts the web server with preview of the Sphinx theme
prepare-theme Prepares and copies files needed for the proper functioning of the sphinx theme.
build-landing-pages Builds a landing pages
build-site Builds a website with documentation
check-site-links Checks if the links are correct in the website
Expand Down Expand Up @@ -222,6 +224,7 @@ function build_site {
EOF
}


function cleanup_environment {
container_status="$(docker inspect "${CONTAINER_NAME}" --format '{{.State.Status}}')"
echo "Current container status: ${container_status}"
Expand All @@ -241,6 +244,16 @@ function cleanup_environment {
fi
}

function prepare_theme {
SITE_DIST="landing-pages/dist"
THEME_GEN="sphinx_airflow_theme/sphinx_airflow_theme/static/_gen"
mkdir -p "${THEME_GEN}/css" "${THEME_GEN}/js"
cp ${SITE_DIST}/docs.*.js "${THEME_GEN}/js/docs.js"
cp ${SITE_DIST}/scss/main.min.*.css "${THEME_GEN}/css/main.min.css"
cp ${SITE_DIST}/scss/main-custom.min.*.css "${THEME_GEN}/css/main-custom.min.css"
echo "Successful copied required files"
}

if [[ "$#" -eq 0 ]]; then
echo "You must provide at least one command."
echo
Expand Down Expand Up @@ -289,6 +302,9 @@ elif [[ "${CMD}" == "check-site-links" ]]; then
ensure_node_module_exists
ensure_that_website_is_build
run_command "/opt/site/landing-pages/" ./check-links.sh
elif [[ "${CMD}" == "prepare-theme" ]]; then
ensure_that_website_is_build
prepare_theme
elif [[ "${CMD}" == "lint-js" ]]; then
ensure_node_module_exists
if [[ "$#" -eq 0 ]]; then
Expand Down
20 changes: 20 additions & 0 deletions sphinx_airflow_theme/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

# Sphinx theme for Airflow
Binary file added sphinx_airflow_theme/demo/awesome-cat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions sphinx_airflow_theme/demo/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------

project = 'Theme demo'
copyright = '2019, Apache Software Foundation'
author = 'Apache Software Foundation'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# Custom sidebar templates,
html_sidebars = {
'**': [
'version-selector.html',
'searchbox.html',
'globaltoc.html',
]
}

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_airflow_theme'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
Loading

0 comments on commit 91f760c

Please sign in to comment.