diff --git a/.github/workflows/asciidoc-convert-check.yml b/.github/workflows/asciidoc-convert-check.yml index 9df28b8..6881872 100644 --- a/.github/workflows/asciidoc-convert-check.yml +++ b/.github/workflows/asciidoc-convert-check.yml @@ -46,6 +46,7 @@ jobs: "overview/resources.adoc" "overview/routing.adoc" "overview/security.adoc" + "overview/load.adoc" "kubernetes/deployment-concerns.adoc" ) for file in "${files[@]}"; do diff --git a/Makefile b/Makefile index edc300d..77383ea 100644 --- a/Makefile +++ b/Makefile @@ -23,4 +23,4 @@ export PYTHONPATH := python .PHONY: generate-preview generate-preview: - bash ./scripts/convert-all.sh + python ./scripts/convert-all.py ./scripts/convert-adoc.sh .github/workflows/asciidoc-convert-check.yml diff --git a/README.adoc b/README.adoc index 1de1471..7798429 100644 --- a/README.adoc +++ b/README.adoc @@ -22,7 +22,12 @@ If you want to preview changes for more complex contributions, follow this proce . Start the build: + ---- -$ bash scripts/convert-all.sh +$ python scripts/convert-all.py ./scripts/convert +-adoc.sh .github/workflows/asciidoc-convert-check.yml ---- +* `convert-adoc.sh` converts each adoc to HTML +* `.github/workflows/asciidoc-convert-check.yml` is the single source of truth about which adoc files are published, see [GitHub: Source code for the Skupper project website]( https://github.com/skupperproject/skupper-website ). + + . See the `build` directory for the HTML output. diff --git a/scripts/convert-adoc.sh b/scripts/convert-adoc.sh old mode 100644 new mode 100755 diff --git a/scripts/convert-all.py b/scripts/convert-all.py new file mode 100644 index 0000000..c6c2c8e --- /dev/null +++ b/scripts/convert-all.py @@ -0,0 +1,58 @@ +import yaml +import subprocess +import os +import argparse + +# Function to parse command-line arguments +def parse_args(): + parser = argparse.ArgumentParser(description="Process AsciiDoc files using a specified script.") + parser.add_argument('script', help="Path to the script to process AsciiDoc files.") + parser.add_argument('yaml_file', help="Path to the YAML file containing the list of AsciiDoc files.") + return parser.parse_args() + +# Function to read the YAML content from a file +def read_yaml(yaml_file): + with open(yaml_file, 'r') as file: + return yaml.safe_load(file) + +# Function to retrieve AsciiDoc files list +def get_asciidoc_files(data): + asciidoc_files = [] + # Navigate through the nested dictionary to find the 'files' list + for job_name, job_details in data.get('jobs', {}).items(): + steps = job_details.get('steps', []) + for step in steps: + if step.get('name') == 'Convert specified AsciiDoc files to HTML': + run_content = step.get('run', '') + if 'files=(' in run_content: + start = run_content.find('files=(') + len('files=(') + end = run_content.find(')', start) + files_list = run_content[start:end].strip().split('\n') + # Clean and add the files to the list + for file in files_list: + clean_file = file.strip().strip('"') + if clean_file: + asciidoc_files.append(clean_file) + return asciidoc_files + +# Function to run the specified script against each AsciiDoc file +def process_asciidoc_file(script, file): + # Check if the script exists + if not os.path.exists(script): + print(f"Script not found: {script}") + return + # Execute the script with the file as an argument using bash + result = subprocess.run(['bash', script, file], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + print(result.stdout) # Print or handle the output as needed + if result.stderr: + print(f"Error processing {file}: {result.stderr}") + +def main(): + args = parse_args() + data = read_yaml(args.yaml_file) + asciidoc_files = get_asciidoc_files(data) + for file in asciidoc_files: + process_asciidoc_file(args.script, file) + +if __name__ == "__main__": + main() diff --git a/scripts/convert-all.sh b/scripts/convert-all.sh deleted file mode 100644 index 773fc54..0000000 --- a/scripts/convert-all.sh +++ /dev/null @@ -1,17 +0,0 @@ -bash scripts/convert-adoc.sh \ -cli/index.adoc \ -cli/tokens.adoc \ -cli/podman.adoc \ -cli/native-security-options.adoc \ -yaml/index.adoc \ -operator/index.adoc \ -console/index.adoc \ -policy/index.adoc \ -troubleshooting/index.adoc \ -overview/connectivity.adoc \ -overview/glossary.adoc \ -overview/index.adoc \ -overview/resources.adoc \ -overview/routing.adoc \ -overview/security.adoc \ -kubernetes/deployment-concerns.adoc