mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-04-28 10:26:54 +02:00
Compare commits
9 Commits
2095f16402
...
74edb197de
Author | SHA1 | Date | |
---|---|---|---|
74edb197de | |||
871dc04fc9 | |||
c4943ef3b3 | |||
6a1d6e40a7 | |||
b6eb9a0dd3 | |||
c9c716e5fe | |||
18fba35173 | |||
3e1a9e9dde | |||
985ed797bd |
@ -1,11 +1,10 @@
|
|||||||
# License Agreement
|
# CyMaIS NonCommercial License (CNCL)
|
||||||
## CyMaIS NonCommercial License (CNCL)
|
|
||||||
|
|
||||||
### Definitions
|
## Definitions
|
||||||
- **"Software":** Refers to *"[CyMaIS - Cyber Master Infrastructure Solution](https://cymais.cloud/)"* and its associated source code.
|
- **"Software":** Refers to *"[CyMaIS - Cyber Master Infrastructure Solution](https://cymais.cloud/)"* and its associated source code.
|
||||||
- **"Commercial Use":** Any use of the Software intended for direct or indirect financial gain, including but not limited to sales, rentals, or provision of services.
|
- **"Commercial Use":** Any use of the Software intended for direct or indirect financial gain, including but not limited to sales, rentals, or provision of services.
|
||||||
|
|
||||||
### Provisions
|
## Provisions
|
||||||
|
|
||||||
1. **Attribution of the Original Licensor:** In any distribution or publication of the Software or derivative works, the original licensor, *Kevin Veen-Birkenbach, Email: [license@veen.world](mailto:license@veen.world), Website: [https://www.veen.world/](https://www.veen.world/)* must be explicitly named.
|
1. **Attribution of the Original Licensor:** In any distribution or publication of the Software or derivative works, the original licensor, *Kevin Veen-Birkenbach, Email: [license@veen.world](mailto:license@veen.world), Website: [https://www.veen.world/](https://www.veen.world/)* must be explicitly named.
|
||||||
|
|
||||||
@ -24,5 +23,5 @@
|
|||||||
|
|
||||||
7. **Ownership of Rights:** All rights, including copyright, trademark, and other forms of intellectual property related to the Software, belong exclusively to Kevin Veen-Birkenbach.
|
7. **Ownership of Rights:** All rights, including copyright, trademark, and other forms of intellectual property related to the Software, belong exclusively to Kevin Veen-Birkenbach.
|
||||||
|
|
||||||
### Consent
|
## Consent
|
||||||
By using, modifying, or distributing the Software, you agree to these terms.
|
By using, modifying, or distributing the Software, you agree to these terms.
|
@ -1,5 +1,4 @@
|
|||||||
# CyMaIS
|
# CyMaIS - Cyber Master Infrastructure Solution
|
||||||
## Cyber Master Infrastructure Solution
|
|
||||||
[](https://github.com/sponsors/kevinveenbirkenbach) [](https://www.patreon.com/c/kevinveenbirkenbach) [](https://buymeacoffee.com/kevinveenbirkenbach) [](https://s.veen.world/paypaldonate)
|
[](https://github.com/sponsors/kevinveenbirkenbach) [](https://www.patreon.com/c/kevinveenbirkenbach) [](https://buymeacoffee.com/kevinveenbirkenbach) [](https://s.veen.world/paypaldonate)
|
||||||
|
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ Our intuitive interface, coupled with in-depth documentation, makes it accessibl
|
|||||||
|
|
||||||
With CyMaIS, setting up a secure, scalable, and robust IT infrastructure is not just faster and easier, but also aligned with the best industry practices, ensuring that your organization stays ahead in the ever-evolving digital landscape.
|
With CyMaIS, setting up a secure, scalable, and robust IT infrastructure is not just faster and easier, but also aligned with the best industry practices, ensuring that your organization stays ahead in the ever-evolving digital landscape.
|
||||||
|
|
||||||
### Vision
|
## Vision
|
||||||
Our project is anchored in the vision of transforming IT infrastructure deployment into a seamless, secure, and scalable experience.
|
Our project is anchored in the vision of transforming IT infrastructure deployment into a seamless, secure, and scalable experience.
|
||||||
|
|
||||||
We are committed to developing a fully automated solution that enables businesses of any size and industry to set up a 100% secure and infinitely scalable IT infrastructure in just 24 hours.
|
We are committed to developing a fully automated solution that enables businesses of any size and industry to set up a 100% secure and infinitely scalable IT infrastructure in just 24 hours.
|
||||||
@ -46,7 +45,7 @@ For a deeper understanding of our goals and the ethos driving our project, we in
|
|||||||
|
|
||||||
CyMaIS is more than just an IT solution; it's a commitment to empowering your business with the technology it needs to thrive in today’s digital landscape, effortlessly and securely.
|
CyMaIS is more than just an IT solution; it's a commitment to empowering your business with the technology it needs to thrive in today’s digital landscape, effortlessly and securely.
|
||||||
|
|
||||||
### Professional CyMaIS Implementation
|
## Professional CyMaIS Implementation
|
||||||
<img src="https://cybermaster.space/wp-content/uploads/sites/7/2023/11/FVG_8364BW-scaled.jpg" width="300" style="float: right; margin-left: 30px;">
|
<img src="https://cybermaster.space/wp-content/uploads/sites/7/2023/11/FVG_8364BW-scaled.jpg" width="300" style="float: right; margin-left: 30px;">
|
||||||
|
|
||||||
My name is Kevin Veen-Birkenbach and I'm glad to assist you in the implementation of your secure and scalable IT infrastrucutre solution with CyMaIS.
|
My name is Kevin Veen-Birkenbach and I'm glad to assist you in the implementation of your secure and scalable IT infrastrucutre solution with CyMaIS.
|
||||||
@ -61,6 +60,6 @@ Contact me for more details:
|
|||||||
📧 Email: [kevin@veen.world](mailto:kevin@veen.world)<br />
|
📧 Email: [kevin@veen.world](mailto:kevin@veen.world)<br />
|
||||||
☎️ Phone: [+ 49 178 179 80 23](tel:00491781798023)
|
☎️ Phone: [+ 49 178 179 80 23](tel:00491781798023)
|
||||||
|
|
||||||
### License
|
## License
|
||||||
|
|
||||||
This project is licensed from Kevin Veen-Birkenbach. The full license is available in the [LICENSE.md](./LICENSE.md) of this repository.
|
This project is licensed from Kevin Veen-Birkenbach. The full license is available in the [LICENSE.md](./LICENSE.md) of this repository.
|
||||||
|
@ -549,9 +549,9 @@ defaults_applications:
|
|||||||
|
|
||||||
## Sphinx
|
## Sphinx
|
||||||
sphinx:
|
sphinx:
|
||||||
version: "3.9-slim" # Use latest docker image
|
version: "3.9-slim" # Use latest docker image
|
||||||
volumes:
|
repository_sphinx_source: "https://github.com/kevinveenbirkenbach/cymais.git" # Repository address to pull the source repository from
|
||||||
source_dir: "{ansible_playbook_dir}" # Path from which sphinx reads the documentation
|
sphinx_exec_dir_relative: "sphinx/" # The relative path to the sphinx Makefile folder from the source dir
|
||||||
|
|
||||||
|
|
||||||
## Taiga
|
## Taiga
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
# Applications by Category
|
Applications by Category
|
||||||
|
=========================
|
||||||
|
|
||||||
.. roles-overview::
|
.. roles-overview::
|
@ -676,6 +676,7 @@ navigation:
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
- name: Support Us
|
- name: Support Us
|
||||||
description: "Discover all the ways you can support our work."
|
description: "Discover all the ways you can support our work."
|
||||||
icon:
|
icon:
|
||||||
@ -701,13 +702,17 @@ navigation:
|
|||||||
icon:
|
icon:
|
||||||
class: fa-brands fa-github
|
class: fa-brands fa-github
|
||||||
url: https://s.veen.world/githubsponsors
|
url: https://s.veen.world/githubsponsors
|
||||||
{% if "spinx" in group_names %}
|
|
||||||
- name: Documentation & Support
|
{% if "sphinx" in group_names %}
|
||||||
|
|
||||||
|
- name: Documentation
|
||||||
description: Access our comprehensive documentation and support resources to help you get the most out of the software.
|
description: Access our comprehensive documentation and support resources to help you get the most out of the software.
|
||||||
icon:
|
icon:
|
||||||
class: fas fa-book
|
class: fas fa-book
|
||||||
url: https://{{domains.sphinx}}
|
url: https://{{domains.sphinx}}
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
- name: Imprint
|
- name: Imprint
|
||||||
description: Check out the imprint information
|
description: Check out the imprint information
|
||||||
icon:
|
icon:
|
||||||
|
33
roles/docker-sphinx/files/Dockerfile
Normal file
33
roles/docker-sphinx/files/Dockerfile
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
ARG DOCKER_PYTHON_VERSION
|
||||||
|
FROM python:${DOCKER_PYTHON_VERSION}
|
||||||
|
|
||||||
|
ARG SPHINX_SOURCE_DIR
|
||||||
|
ARG SPHINX_BUILD_DIR
|
||||||
|
ARG SPHINX_EXEC_DIR
|
||||||
|
ARG SPHINX_APP_DIR
|
||||||
|
ARG SPHINX_SOURCE_DIR_RELATIVE
|
||||||
|
|
||||||
|
# Set the environment variables so they are available during build for Makefile
|
||||||
|
ENV SPHINX_SOURCE_DIR=${SPHINX_SOURCE_DIR}
|
||||||
|
ENV SPHINX_BUILD_DIR=${SPHINX_BUILD_DIR}
|
||||||
|
|
||||||
|
# Install required packages
|
||||||
|
RUN apt-get update && apt-get install -y make curl
|
||||||
|
|
||||||
|
# Set the working directory
|
||||||
|
WORKDIR ${SPHINX_APP_DIR}
|
||||||
|
|
||||||
|
# Copy the project files into the container
|
||||||
|
COPY ${SPHINX_SOURCE_DIR_RELATIVE} ${SPHINX_APP_DIR}
|
||||||
|
|
||||||
|
# Install Python packages via requirements.txt
|
||||||
|
RUN cd ${SPHINX_EXEC_DIR} && pip install --upgrade pip && pip install -r requirements.txt
|
||||||
|
|
||||||
|
# Build the HTML documentation using Sphinx with the defined directories
|
||||||
|
RUN cd ${SPHINX_EXEC_DIR} && make html
|
||||||
|
|
||||||
|
# Expose port 8000 where the HTTP server will run
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
# Start a simple HTTP server to serve the built documentation
|
||||||
|
CMD python -m http.server 8000 --directory "${SPHINX_BUILD_DIR}html/"
|
@ -4,12 +4,19 @@
|
|||||||
include_role:
|
include_role:
|
||||||
name: docker-compose
|
name: docker-compose
|
||||||
|
|
||||||
- name: pull cymais repository
|
- name: "Create {{ host_sphinx_source_dir_absolute }} directory"
|
||||||
|
file:
|
||||||
|
path: "{{ host_sphinx_source_dir_absolute }}"
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: pull the source repository to build the Sphinx documentation from {{ applications.sphinx.repository_sphinx_source }}
|
||||||
git:
|
git:
|
||||||
repo: "{{ repository_address_cymais }}"
|
repo: "{{ applications.sphinx.repository_sphinx_source }}"
|
||||||
dest: "{{ host_cymais_volume_dir_absolute }}"
|
dest: "{{ host_sphinx_source_dir_absolute }}"
|
||||||
update: yes
|
update: yes
|
||||||
notify: docker compose project setup
|
clone: yes
|
||||||
|
notify: docker compose project build and setup
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: "include role nginx-domain-setup for {{application_id}}"
|
- name: "include role nginx-domain-setup for {{application_id}}"
|
||||||
@ -20,12 +27,12 @@
|
|||||||
http_port: "{{ ports.localhost.http[application_id] }}"
|
http_port: "{{ ports.localhost.http[application_id] }}"
|
||||||
|
|
||||||
- name: "create {{ sphinx_docker_file }}"
|
- name: "create {{ sphinx_docker_file }}"
|
||||||
template:
|
copy:
|
||||||
src: "Dockerfile.j2"
|
src: "Dockerfile"
|
||||||
dest: "{{ sphinx_docker_file }}"
|
dest: "{{ sphinx_docker_file }}"
|
||||||
mode: '770'
|
mode: '770'
|
||||||
force: yes
|
force: yes
|
||||||
notify: docker compose project setup
|
notify: docker compose project build and setup
|
||||||
|
|
||||||
- name: "copy docker-compose.yml and env file"
|
- name: "copy docker-compose.yml and env file"
|
||||||
include_tasks: copy-docker-compose-and-env.yml
|
include_tasks: copy-docker-compose-and-env.yml
|
@ -1,22 +0,0 @@
|
|||||||
FROM python:{{applications[application_id].version}}
|
|
||||||
|
|
||||||
# Install required packages including 'make'
|
|
||||||
RUN apt-get update && apt-get install -y make
|
|
||||||
|
|
||||||
# Set the working directory
|
|
||||||
WORKDIR {{docker_app_dir}}
|
|
||||||
|
|
||||||
# Copy the project files into the container
|
|
||||||
COPY {{host_cymais_volume_dir_relative}} {{docker_app_dir}}
|
|
||||||
|
|
||||||
# Install Python packages via requirements.txt
|
|
||||||
RUN cd {{docker_sphinx_dir}} && pip install --upgrade pip && pip install -r requirements.txt
|
|
||||||
|
|
||||||
# Build the HTML documentation using Sphinx with the defined directories
|
|
||||||
RUN cd {{docker_sphinx_dir}} && make html
|
|
||||||
|
|
||||||
# Expose port 8000 where the HTTP server will run
|
|
||||||
EXPOSE 8000
|
|
||||||
|
|
||||||
# Start a simple HTTP server to serve the built documentation
|
|
||||||
CMD ["python", "-m", "http.server", "8000", "--directory", "${BUILD_DIR}"]
|
|
@ -1,6 +1,15 @@
|
|||||||
services:
|
services:
|
||||||
application:
|
application:
|
||||||
build: .
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
SPHINX_SOURCE_DIR: {{docker_source_dir}}
|
||||||
|
SPHINX_BUILD_DIR: {{docker_output_dir}}
|
||||||
|
SPHINX_EXEC_DIR: {{docker_exec_dir}}
|
||||||
|
SPHINX_APP_DIR: {{docker_app_dir}}
|
||||||
|
SPHINX_SOURCE_DIR_RELATIVE: {{host_sphinx_source_dir_relative}}
|
||||||
|
DOCKER_PYTHON_VERSION: {{applications[application_id].version}}
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:{{ports.localhost.http[application_id]}}:8000"
|
- "127.0.0.1:{{ports.localhost.http[application_id]}}:8000"
|
||||||
healthcheck:
|
healthcheck:
|
||||||
@ -8,6 +17,7 @@ services:
|
|||||||
interval: 1m
|
interval: 1m
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}
|
||||||
{% include 'templates/docker/container/networks.yml.j2' %}
|
{% include 'templates/docker/container/networks.yml.j2' %}
|
||||||
|
|
||||||
{% include 'templates/docker/compose/networks.yml.j2' %}
|
{% include 'templates/docker/compose/networks.yml.j2' %}
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
SOURCE_DIR={{docker_source_dir}}
|
|
||||||
BUILD_DIR={{docker_output_dir}}
|
|
@ -1,13 +1,11 @@
|
|||||||
application_id: "sphinx"
|
application_id: "sphinx"
|
||||||
|
|
||||||
repository_address_cymais: "https://github.com/kevinveenbirkenbach/cymais.git" # Repository address to pull cymais from
|
host_sphinx_source_dir_relative: "volumes/source/" # Place where the sphinx source repository is stored on the host
|
||||||
|
host_sphinx_source_dir_absolute: "{{docker_compose.directories.instance}}{{host_sphinx_source_dir_relative}}" # Place where the sphinx source repository is stored on the host
|
||||||
|
|
||||||
host_cymais_volume_dir_absolute: "{{docker_compose.directories.volumes}}cymais/" # Place where the cymais repository is stored on the host
|
docker_app_dir: "/app/" # Folder in which the application is running
|
||||||
host_cymais_volume_dir_relative: "volumes/cymais/" # Place where the cymais repository is stored on the host
|
docker_source_dir: "{{docker_app_dir}}" # Folder which is used to be screened
|
||||||
|
docker_output_dir: "/docs/" # Folder to which the output is fuuuucking putted!
|
||||||
|
docker_exec_dir: "{{docker_app_dir}}{{applications.sphinx.sphinx_exec_dir_relative}}" # Folder which contains the sphinxs makefile and logic
|
||||||
|
|
||||||
docker_app_dir: "/app/" # Folder in which the application is running
|
sphinx_docker_file: "{{ docker_compose.directories.instance }}Dockerfile" # Path to the Dockerfile to build sphinx
|
||||||
docker_source_dir: "{{docker_app_dir}}" # Folder which is used to be screened
|
|
||||||
docker_output_dir: "/docs/" # Folder to which the output is fuuuucking putted!
|
|
||||||
docker_sphinx_dir: "{{docker_app_dir}}/sphinx/" # Folder which contains the sphinxs makefile and logic
|
|
||||||
|
|
||||||
sphinx_docker_file: "{{ docker_compose.directories.instance }}/Dockerfile"
|
|
@ -1,4 +1,5 @@
|
|||||||
# Application Glosar
|
Application Glosar
|
||||||
|
===================
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 1
|
:maxdepth: 1
|
||||||
|
@ -602,10 +602,24 @@ html[native-dark-active] my-app button, button {
|
|||||||
--card-header-accent: var(--color-85); /* Accent color in card headers */
|
--card-header-accent: var(--color-85); /* Accent color in card headers */
|
||||||
|
|
||||||
/* Dropdown Menus */
|
/* Dropdown Menus */
|
||||||
--dropdown-item-hover-bg: var(--color-05); /* Hover background: very dark */
|
--dropdown-item-hover-bg: var(--color-05); /* Hover background: very dark */
|
||||||
--dropdown-item-hover-color: var(--color-60); /* Hover text: a bit lighter */
|
--dropdown-item-hover-color: var(--color-60); /* Hover text: a bit lighter */
|
||||||
--dropdown-item-color: var(--color-70); /* Regular dropdown item text */
|
--dropdown-item-color: var(--color-70); /* Regular dropdown item text */
|
||||||
--dropdown-item-active-color: var(--color-99);/* Active state: very light (white) */
|
--dropdown-item-active-color: var(--color-99); /* Active state: very light (white) */
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sphinx **/
|
||||||
|
.bg-background\/95 {
|
||||||
|
background-color: var(--color-96);
|
||||||
|
}
|
||||||
|
|
||||||
|
.border-border {
|
||||||
|
border-color: var(--color-85);
|
||||||
|
}
|
||||||
|
|
||||||
|
{# Hide Toogle Button #}
|
||||||
|
nav.flex.items-center.space-x-1{
|
||||||
|
display:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Taiga **/
|
/** Taiga **/
|
||||||
|
@ -2,19 +2,19 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
# You can set these variables from the command line, and also
|
# You can set these variables from the command line, and also
|
||||||
# from the environment for the first two.
|
# from the environment
|
||||||
SPHINXOPTS ?= -c .
|
SPHINXOPTS ?= -c .
|
||||||
SPHINXBUILD ?= sphinx-build
|
SPHINXBUILD ?= sphinx-build
|
||||||
SOURCE_DIR = ../
|
SPHINX_SOURCE_DIR ?= ../
|
||||||
BUILD_DIR = ../docs
|
SPHINX_BUILD_DIR ?= ../docs
|
||||||
|
|
||||||
# Put it first so that "make" without argument is like "make help".
|
# Put it first so that "make" without argument is like "make help".
|
||||||
help:
|
help:
|
||||||
@$(SPHINXBUILD) -M help "$(SOURCE_DIR)" "$(BUILD_DIR)" $(SPHINXOPTS) $(O)
|
@$(SPHINXBUILD) -M help "$(SPHINX_SOURCE_DIR)" "$(SPHINX_BUILD_DIR)" $(SPHINXOPTS) $(O)
|
||||||
|
|
||||||
.PHONY: help install Makefile
|
.PHONY: help install Makefile
|
||||||
|
|
||||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||||
%: Makefile
|
%: Makefile
|
||||||
@$(SPHINXBUILD) -M $@ "$(SOURCE_DIR)" "$(BUILD_DIR)" $(SPHINXOPTS) $(O)
|
@$(SPHINXBUILD) -M $@ "$(SPHINX_SOURCE_DIR)" "$(SPHINX_BUILD_DIR)" $(SPHINXOPTS) $(O)
|
||||||
|
@ -1,25 +1,19 @@
|
|||||||
|
{% macro render_headings(headings) %}
|
||||||
|
<ul>
|
||||||
|
{% for item in headings %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ pathto(item.link).replace("#", "") + '#' + item.anchor }}">{{ item.text }}</a>
|
||||||
|
{% if item.children %}
|
||||||
|
{{ render_headings(item.children) }}
|
||||||
|
{% endif %}
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
{% if local_md_headings %}
|
{% if local_md_headings %}
|
||||||
<div class="local-md-headings">
|
<div class="local-md-headings">
|
||||||
<h3>Page Headings</h3>
|
<h3>Overview</h3>
|
||||||
{% set ns = namespace(current_level=0) %}
|
{{ render_headings(local_md_headings) }}
|
||||||
{% for item in local_md_headings %}
|
|
||||||
{# If the current heading level is greater than the previous, open new <ul> tags #}
|
|
||||||
{% if item.level > ns.current_level %}
|
|
||||||
{% for i in range(ns.current_level, item.level) %}
|
|
||||||
<ul>
|
|
||||||
{% endfor %}
|
|
||||||
{# If the current heading level is less than the previous, close the open <ul> tags #}
|
|
||||||
{% elif item.level < ns.current_level %}
|
|
||||||
{% for i in range(item.level, ns.current_level) %}
|
|
||||||
</ul>
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
<li><a href="{{ pathto(item.link).replace("#","") + "#" + item.anchor}}">{{ item.text }}</a></li>
|
|
||||||
{% set ns.current_level = item.level %}
|
|
||||||
{% endfor %}
|
|
||||||
{# Close any remaining open <ul> tags #}
|
|
||||||
{% for i in range(ns.current_level) %}
|
|
||||||
</ul>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -25,25 +25,25 @@ exclude_patterns = ['docs', 'venv', 'venv/**']
|
|||||||
# -- Options for HTML output -------------------------------------------------
|
# -- Options for HTML output -------------------------------------------------
|
||||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
||||||
|
|
||||||
html_theme = 'alabaster'
|
html_theme = 'sphinxawesome_theme'
|
||||||
html_static_path = ['_static']
|
html_static_path = ['_static']
|
||||||
|
|
||||||
html_sidebars = {
|
html_sidebars = {
|
||||||
'**': [
|
'**': [
|
||||||
'globaltoc.html',
|
#'globaltoc.html',
|
||||||
'relations.html',
|
# 'relations.html',
|
||||||
'sourcelink.html',
|
# 'sourcelink.html',
|
||||||
'local_md_files.html', # Include your custom template
|
'local_md_files.html', # Include your custom template
|
||||||
'searchbox.html',
|
# 'searchbox.html',
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
html_theme_options = {
|
html_theme_options = {
|
||||||
'fixed_sidebar': True,
|
# 'fixed_sidebar': True,
|
||||||
|
"show_prev_next": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Liste der Dateiendungen, die Sphinx verarbeiten soll:
|
|
||||||
source_suffix = {
|
source_suffix = {
|
||||||
'.rst': 'restructuredtext',
|
'.rst': 'restructuredtext',
|
||||||
'.md': 'markdown',
|
'.md': 'markdown',
|
||||||
@ -59,10 +59,8 @@ extensions = [
|
|||||||
]
|
]
|
||||||
autosummary_generate = True
|
autosummary_generate = True
|
||||||
|
|
||||||
# Optional: Zusätzliche MyST-Konfigurationen
|
|
||||||
myst_enable_extensions = [
|
myst_enable_extensions = [
|
||||||
"colon_fence", # Für erweiterte Syntax wie ::: Hinweisboxen etc.
|
"colon_fence",
|
||||||
# weitere Erweiterungen nach Bedarf
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
|
@ -4,8 +4,9 @@ from sphinx.util import logging
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Set the maximum heading level to include (e.g., include headings up to H3)
|
# Set the maximum heading level for Markdown headings
|
||||||
MAX_HEADING_LEVEL = 3
|
MAX_HEADING_LEVEL = 3
|
||||||
|
DEFAULT_MAX_NAV_DEPTH = 2 # Default maximum navigation depth; configurable via conf.py
|
||||||
|
|
||||||
def natural_sort_key(text):
|
def natural_sort_key(text):
|
||||||
"""
|
"""
|
||||||
@ -16,30 +17,38 @@ def natural_sort_key(text):
|
|||||||
|
|
||||||
def extract_headings_from_file(filepath, max_level=MAX_HEADING_LEVEL):
|
def extract_headings_from_file(filepath, max_level=MAX_HEADING_LEVEL):
|
||||||
"""
|
"""
|
||||||
Extract Markdown headings (up to max_level) from the file at filepath.
|
Extract headings from a file.
|
||||||
Skips fenced code blocks.
|
For Markdown files, look for lines starting with '#' (up to max_level).
|
||||||
|
For reStructuredText files, look for a line immediately followed by an underline made of punctuation.
|
||||||
"""
|
"""
|
||||||
headings = []
|
headings = []
|
||||||
|
ext = os.path.splitext(filepath)[1].lower()
|
||||||
try:
|
try:
|
||||||
with open(filepath, 'r', encoding='utf-8') as f:
|
with open(filepath, 'r', encoding='utf-8') as f:
|
||||||
in_code_block = False
|
if ext == '.md':
|
||||||
for line in f:
|
in_code_block = False
|
||||||
# Toggle code block state if a line starts with ```
|
for line in f:
|
||||||
if line.strip().startswith("```"):
|
if line.strip().startswith("```"):
|
||||||
in_code_block = not in_code_block
|
in_code_block = not in_code_block
|
||||||
continue
|
continue
|
||||||
if in_code_block:
|
if in_code_block:
|
||||||
continue
|
continue
|
||||||
# Match Markdown headings: one or more '#' followed by a space and the title.
|
match = re.match(r'^(#{1,})\s+(.*)$', line)
|
||||||
match = re.match(r'^(#{1,})\s+(.*)$', line)
|
if match:
|
||||||
if match:
|
level = len(match.group(1))
|
||||||
level = len(match.group(1))
|
if level <= max_level:
|
||||||
if level <= max_level:
|
heading_text = match.group(2).strip()
|
||||||
heading_text = match.group(2).strip()
|
anchor = re.sub(r'\s+', '-', heading_text.lower())
|
||||||
# Create a simple slug for the anchor:
|
anchor = re.sub(r'[^a-z0-9\-]', '', anchor)
|
||||||
# - convert to lowercase
|
headings.append({'level': level, 'text': heading_text, 'anchor': anchor})
|
||||||
# - replace spaces with hyphens
|
elif ext == '.rst':
|
||||||
# - remove non-alphanumeric characters (except hyphens)
|
lines = f.readlines()
|
||||||
|
for i in range(len(lines)-1):
|
||||||
|
text_line = lines[i].rstrip("\n")
|
||||||
|
underline = lines[i+1].rstrip("\n")
|
||||||
|
if len(underline) >= 3 and re.fullmatch(r'[-=~\^\+"\'`]+', underline):
|
||||||
|
level = 1 # default level; adjust if needed
|
||||||
|
heading_text = text_line.strip()
|
||||||
anchor = re.sub(r'\s+', '-', heading_text.lower())
|
anchor = re.sub(r'\s+', '-', heading_text.lower())
|
||||||
anchor = re.sub(r'[^a-z0-9\-]', '', anchor)
|
anchor = re.sub(r'[^a-z0-9\-]', '', anchor)
|
||||||
headings.append({'level': level, 'text': heading_text, 'anchor': anchor})
|
headings.append({'level': level, 'text': heading_text, 'anchor': anchor})
|
||||||
@ -47,14 +56,72 @@ def extract_headings_from_file(filepath, max_level=MAX_HEADING_LEVEL):
|
|||||||
logger.warning(f"Error reading {filepath}: {e}")
|
logger.warning(f"Error reading {filepath}: {e}")
|
||||||
return headings
|
return headings
|
||||||
|
|
||||||
|
def group_headings(headings):
|
||||||
|
"""
|
||||||
|
Converts a flat list of headings into a tree structure based on their level.
|
||||||
|
Each heading gets a 'children' list.
|
||||||
|
"""
|
||||||
|
tree = []
|
||||||
|
stack = []
|
||||||
|
for heading in headings:
|
||||||
|
heading['children'] = []
|
||||||
|
while stack and stack[-1]['level'] >= heading['level']:
|
||||||
|
stack.pop()
|
||||||
|
if stack:
|
||||||
|
stack[-1]['children'].append(heading)
|
||||||
|
else:
|
||||||
|
tree.append(heading)
|
||||||
|
stack.append(heading)
|
||||||
|
return tree
|
||||||
|
|
||||||
|
def sort_tree(tree):
|
||||||
|
"""
|
||||||
|
Sorts a list of headings (and their children) first by their 'priority' (default 1)
|
||||||
|
and then by the natural sort key of their text.
|
||||||
|
"""
|
||||||
|
tree.sort(key=lambda x: (x.get('priority', 1), natural_sort_key(x['text'])))
|
||||||
|
|
||||||
|
def collect_nav_items(dir_path, base_url, current_depth, max_depth):
|
||||||
|
"""
|
||||||
|
Recursively collects navigation items from subdirectories.
|
||||||
|
For each subdirectory, if an 'index.rst' exists (preferred) or a 'readme.md' exists,
|
||||||
|
the first heading from that file is used as the title.
|
||||||
|
"""
|
||||||
|
nav_items = []
|
||||||
|
# Look for candidate file in this subdirectory (prefer index.rst, then readme.md)
|
||||||
|
candidate = None
|
||||||
|
for cand in ['index.rst', 'readme.md']:
|
||||||
|
candidate_path = os.path.join(dir_path, cand)
|
||||||
|
if os.path.isfile(candidate_path):
|
||||||
|
candidate = cand
|
||||||
|
break
|
||||||
|
if candidate:
|
||||||
|
candidate_path = os.path.join(dir_path, candidate)
|
||||||
|
headings = extract_headings_from_file(candidate_path)
|
||||||
|
if headings:
|
||||||
|
title = headings[0]['text']
|
||||||
|
else:
|
||||||
|
title = os.path.splitext(candidate)[0].capitalize()
|
||||||
|
# Build link relative to base_url
|
||||||
|
link = os.path.join(base_url, os.path.splitext(candidate)[0])
|
||||||
|
nav_items.append({
|
||||||
|
'level': 1,
|
||||||
|
'text': title,
|
||||||
|
'link': link,
|
||||||
|
'anchor': '',
|
||||||
|
'priority': 0
|
||||||
|
})
|
||||||
|
# Recurse into subdirectories if within max_depth
|
||||||
|
if current_depth < max_depth:
|
||||||
|
for item in os.listdir(dir_path):
|
||||||
|
full_path = os.path.join(dir_path, item)
|
||||||
|
if os.path.isdir(full_path):
|
||||||
|
sub_base_url = os.path.join(base_url, item)
|
||||||
|
nav_items.extend(collect_nav_items(full_path, sub_base_url, current_depth + 1, max_depth))
|
||||||
|
return nav_items
|
||||||
|
|
||||||
def add_local_md_headings(app, pagename, templatename, context, doctree):
|
def add_local_md_headings(app, pagename, templatename, context, doctree):
|
||||||
"""
|
|
||||||
For every Markdown file in the same directory as the current page,
|
|
||||||
extract its headings, sort them in natural ascending order, and add them
|
|
||||||
to the context.
|
|
||||||
"""
|
|
||||||
srcdir = app.srcdir
|
srcdir = app.srcdir
|
||||||
# Determine the directory of the current page (e.g., "directory/file" -> "directory")
|
|
||||||
directory = os.path.dirname(pagename)
|
directory = os.path.dirname(pagename)
|
||||||
abs_dir = os.path.join(srcdir, directory)
|
abs_dir = os.path.join(srcdir, directory)
|
||||||
if not os.path.isdir(abs_dir):
|
if not os.path.isdir(abs_dir):
|
||||||
@ -62,24 +129,49 @@ def add_local_md_headings(app, pagename, templatename, context, doctree):
|
|||||||
context['local_md_headings'] = []
|
context['local_md_headings'] = []
|
||||||
return
|
return
|
||||||
|
|
||||||
|
max_nav_depth = getattr(app.config, 'local_nav_max_depth', DEFAULT_MAX_NAV_DEPTH)
|
||||||
|
|
||||||
|
# Collect navigation items from subdirectories only
|
||||||
|
nav_items = []
|
||||||
|
for item in os.listdir(abs_dir):
|
||||||
|
full_path = os.path.join(abs_dir, item)
|
||||||
|
if os.path.isdir(full_path):
|
||||||
|
nav_items.extend(collect_nav_items(full_path, os.path.join(directory, item), current_depth=1, max_depth=max_nav_depth))
|
||||||
|
|
||||||
|
# Process files in the current directory.
|
||||||
|
files = os.listdir(abs_dir)
|
||||||
|
files_lower = [f.lower() for f in files]
|
||||||
|
# If both index.rst and readme.md exist in the current directory, keep only index.rst.
|
||||||
|
if "index.rst" in files_lower:
|
||||||
|
files = [f for f in files if f.lower() != "readme.md"]
|
||||||
local_md_headings = []
|
local_md_headings = []
|
||||||
for file in os.listdir(abs_dir):
|
for file in files:
|
||||||
if file.endswith('.md'):
|
if file.endswith('.md') or file.endswith('.rst'):
|
||||||
filepath = os.path.join(abs_dir, file)
|
filepath = os.path.join(abs_dir, file)
|
||||||
headings = extract_headings_from_file(filepath)
|
headings = extract_headings_from_file(filepath)
|
||||||
|
basename, _ = os.path.splitext(file)
|
||||||
|
# Set priority: index/readme files get priority 0.
|
||||||
|
if basename.lower() in ['index', 'readme']:
|
||||||
|
priority = 0
|
||||||
|
else:
|
||||||
|
priority = 1
|
||||||
for heading in headings:
|
for heading in headings:
|
||||||
# Build file link: zunächst Pfad + Dateiname, dann Ersetzen der .md-Endung durch .html
|
file_link = os.path.join(directory, basename)
|
||||||
file_link = os.path.join(directory, file).replace(".md","") if directory else file
|
|
||||||
local_md_headings.append({
|
local_md_headings.append({
|
||||||
'level': heading['level'],
|
'level': heading['level'],
|
||||||
'text': heading['text'],
|
'text': heading['text'],
|
||||||
'link': file_link,
|
'link': file_link,
|
||||||
'anchor': heading['anchor']
|
'anchor': heading['anchor'],
|
||||||
|
'priority': priority
|
||||||
})
|
})
|
||||||
# Sort headings in natural ascending order using natural_sort_key.
|
# Combine current directory items with subdirectory nav items.
|
||||||
local_md_headings.sort(key=lambda x: natural_sort_key(x['text']))
|
# If an index or readme from the current directory exists, it will be included only once.
|
||||||
context['local_md_headings'] = local_md_headings
|
all_items = local_md_headings + nav_items
|
||||||
|
tree = group_headings(all_items)
|
||||||
|
sort_tree(tree)
|
||||||
|
context['local_md_headings'] = tree
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
|
app.add_config_value('local_nav_max_depth', DEFAULT_MAX_NAV_DEPTH, 'env')
|
||||||
app.connect('html-page-context', add_local_md_headings)
|
app.connect('html-page-context', add_local_md_headings)
|
||||||
return {'version': '0.1', 'parallel_read_safe': True}
|
return {'version': '0.1', 'parallel_read_safe': True}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
myst-parser
|
myst-parser
|
||||||
sphinx
|
sphinx
|
||||||
sphinx-rtd-theme
|
sphinxawesome-theme
|
||||||
|
Loading…
x
Reference in New Issue
Block a user