Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/web/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Output generated by `hugo`
public/

# Generated by update_docs.py, based the content in <repo-root>/docker/ and additional locations
# Generated by update-docs.py, based on the content in <repo-root>/docker/ and additional locations
src/content/
2 changes: 1 addition & 1 deletion docs/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ COPY docs/web/requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Note: Add parameter for verbose output: --verbose
RUN --mount=type=bind,ro,source=.,target=/repo python -m docs.web.update_docs --repository-path /repo --output-content-path /src/content
RUN --mount=type=bind,ro,source=.,target=/repo /repo/docs/web/update-docs.py --repository-path /repo --output-content-path /src/content

#####################################################################
# Build Stage #
Expand Down
2 changes: 1 addition & 1 deletion docs/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A website is built with the [Hugo](https://gohugo.io/) static site generator, us

## Development

**Build process:** The Markdown and Docker Compose files are collected and converted by `update_docs.py`, then `hugo` build is executed in a Docker container, producing a container image with `nginx` serving the static website.
**Build process:** The Markdown and Docker Compose files are collected and converted by `update-docs.py`, then `hugo` build is executed in a Docker container, producing a container image with `nginx` serving the static website.

Run `task docs:deploy` to build and locally deploy (using `docker/tools/homelab-docs.yaml`) the site.

Expand Down
5 changes: 5 additions & 0 deletions docs/web/Taskfile.web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,8 @@ tasks:
desc: Clear generated documentation content
cmds:
- rm -rf docs/web/public/

create-service-list:
desc: Create a YAML file describing the services
cmds:
- docs/web/export-services.py --output-file docs/services.yaml
3 changes: 0 additions & 3 deletions docs/web/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion docs/web/docker_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
from pathlib import Path

from .compose_processor import ComposeFileProcessor
from compose_processor import ComposeFileProcessor


class DockerComposeScanner:
Expand Down
33 changes: 21 additions & 12 deletions docs/web/export_services.py → docs/web/export-services.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
from pathlib import Path

import yaml

from .docker_scanner import DockerComposeScanner
from .git_utils import get_git_root
from docker_scanner import DockerComposeScanner
from git_utils import get_git_root


def str_presenter(dumper, data):
Expand All @@ -24,11 +23,11 @@ def str_presenter(dumper, data):


def export_services(repository_path, output_file, docker_path="docker", verbose=False):
"""Export all Docker Compose services to a YAML file.
"""Export all Docker Compose services to a YAML file or stdout.

Args:
repository_path: Path to the repository root
output_file: Path to the output YAML file
output_file: Path to the output YAML file, or None for stdout
docker_path: Relative path to docker directory (default: "docker")
verbose: Enable verbose logging
"""
Expand Down Expand Up @@ -69,10 +68,20 @@ def export_services(repository_path, output_file, docker_path="docker", verbose=

output_data["services"].append(service_data)

# Write to YAML file
logger.info(f"Writing {len(services)} services to {output_file}")
with open(output_file, "w") as f:
yaml.dump(output_data, f, width=math.inf, default_flow_style=False, sort_keys=False, allow_unicode=True, Dumper=yaml.Dumper)
# Write to YAML file or stdout
if output_file is not None:
logger.info(f"Writing {len(services)} services to {output_file}")
with open(output_file, "w") as stream:
yaml.dump(
output_data, stream, width=math.inf, default_flow_style=False,
sort_keys=False, allow_unicode=True, indent=2, Dumper=yaml.Dumper
)
else:
logger.info("Writing services to stdout")
yaml.dump(
output_data, sys.stdout, width=math.inf, default_flow_style=False,
sort_keys=False, allow_unicode=True, indent=2, Dumper=yaml.Dumper
)

logger.info("Export complete")

Expand All @@ -90,7 +99,7 @@ def export_services(repository_path, output_file, docker_path="docker", verbose=
parser.add_argument(
"--output-file",
type=str,
help="Specify the output YAML file path"
help="Specify the output YAML file path (defaults to stdout if omitted)"
)
parser.add_argument(
"--docker-path",
Expand All @@ -103,8 +112,8 @@ def export_services(repository_path, output_file, docker_path="docker", verbose=
# Get repository path
repository_path = Path(args.repository_path) if args.repository_path else Path(get_git_root())

# Default output file if not specified
output_file = Path(args.output_file) if args.output_file else repository_path / "services.yaml"
# Default output to stdout if not specified
output_file = Path(args.output_file) if args.output_file else None

# Export services
try:
Expand Down
7 changes: 3 additions & 4 deletions docs/web/update_docs.py → docs/web/update-docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
from pathlib import Path

import yaml

from .docker_scanner import DockerComposeScanner
from .git_utils import get_git_root
from .link_processor import LinkProcessor
from docker_scanner import DockerComposeScanner
from git_utils import get_git_root
from link_processor import LinkProcessor


class DocsProcessor:
Expand Down
Loading