diff --git a/plugins/techdocs/mkdocs/README.md b/plugins/techdocs/mkdocs/README.md index 5126548f54..4d1c11d7b0 100644 --- a/plugins/techdocs/mkdocs/README.md +++ b/plugins/techdocs/mkdocs/README.md @@ -9,5 +9,5 @@ Welcome to MkDocs. This is the TechDocs implementation of MkDocs. ``` docker build ./container -t mkdocs-container - docker run -w /content -v $(pwd)/mock-docs:/content -p 8000:8000 -it mkdocs-container serve -a 0.0.0.0:8000 --theme material + docker run -w /content -v $(pwd)/mock-docs:/content -p 8000:8000 -it mkdocs-container serve -a 0.0.0.0:8000 ``` diff --git a/plugins/techdocs/mkdocs/container/Dockerfile b/plugins/techdocs/mkdocs/container/Dockerfile index 89ca705095..1ae66589b6 100644 --- a/plugins/techdocs/mkdocs/container/Dockerfile +++ b/plugins/techdocs/mkdocs/container/Dockerfile @@ -1,7 +1,25 @@ + +# Copyright 2020 Spotify AB +# +# Licensed 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. + FROM python:3.7.7-alpine3.12 RUN apk update && apk --no-cache add gcc musl-dev RUN pip install mkdocs==1.1.2 mkdocs-material==5.3.2 +ADD ./techdocs-core /techdocs-core +RUN pip install --no-index /techdocs-core + ENTRYPOINT [ "mkdocs" ] diff --git a/plugins/techdocs/mkdocs/container/techdocs-core/requirements.txt b/plugins/techdocs/mkdocs/container/techdocs-core/requirements.txt new file mode 100644 index 0000000000..b3667f94ec --- /dev/null +++ b/plugins/techdocs/mkdocs/container/techdocs-core/requirements.txt @@ -0,0 +1 @@ +mkdocs==1.1.2 diff --git a/plugins/techdocs/mkdocs/container/techdocs-core/setup.py b/plugins/techdocs/mkdocs/container/techdocs-core/setup.py new file mode 100644 index 0000000000..faa8b8c46e --- /dev/null +++ b/plugins/techdocs/mkdocs/container/techdocs-core/setup.py @@ -0,0 +1,48 @@ +""" + * Copyright 2020 Spotify AB + * + * Licensed 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. +""" +from setuptools import setup, find_packages + + +setup( + name='mkdocs-techdocs-core', + version='0.0.1', + description='A Mkdocs package that contains TechDocs defaults', + long_description='', + keywords='mkdocs', + url='https://github.com/spotify/backstage', + author='Spotify', + author_email='fossboard@spotify.com', + license='Apache-2.0', + python_requires='>=3.7', + install_requires=[ + 'mkdocs>=1.1.2' + ], + classifiers=[ + 'Development Status :: 1 - Planning', + 'Intended Audience :: Developers', + 'Intended Audience :: Information Technology', + 'License :: OSI Approved :: Apache Software License', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3.7' + ], + packages=find_packages(), + entry_points={ + 'mkdocs.plugins': [ + 'techdocs-core = src.core:TechDocsCore' + ] + } +) diff --git a/plugins/techdocs/mkdocs/container/techdocs-core/src/__init__.py b/plugins/techdocs/mkdocs/container/techdocs-core/src/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py b/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py new file mode 100644 index 0000000000..e42a60d28b --- /dev/null +++ b/plugins/techdocs/mkdocs/container/techdocs-core/src/core.py @@ -0,0 +1,35 @@ +""" + * Copyright 2020 Spotify AB + * + * Licensed 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. +""" + +from mkdocs.plugins import BasePlugin, PluginCollection +from mkdocs.theme import Theme + +from mkdocs.contrib.search import SearchPlugin + +class TechDocsCore(BasePlugin): + def on_config(self, config): + # Theme + config['theme'] = Theme(name="material") + + # Plugins + del config['plugins']['techdocs-core'] + + search_plugin = SearchPlugin() + search_plugin.load_config({}) + config['plugins']['search'] = search_plugin + + return config + diff --git a/plugins/techdocs/mkdocs/mock-docs/.gitignore b/plugins/techdocs/mkdocs/mock-docs/.gitignore new file mode 100644 index 0000000000..45ddf0ae39 --- /dev/null +++ b/plugins/techdocs/mkdocs/mock-docs/.gitignore @@ -0,0 +1 @@ +site/ diff --git a/plugins/techdocs/mkdocs/mock-docs/mkdocs.yml b/plugins/techdocs/mkdocs/mock-docs/mkdocs.yml index c8370ae3ac..b14d82c4de 100644 --- a/plugins/techdocs/mkdocs/mock-docs/mkdocs.yml +++ b/plugins/techdocs/mkdocs/mock-docs/mkdocs.yml @@ -2,3 +2,7 @@ site_name: 'mock-docs' nav: - Home: index.md + +plugins: + - techdocs-core +