diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7f7b466b..d38a2895 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,7 +38,7 @@ jobs: uses: actions/checkout@v4.1.7 - id: changes name: Check for file changes - uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd # v3.0.0 + uses: dorny/paths-filter@v3.0.2 with: base: ${{ github.ref }} token: ${{ github.token }} diff --git a/docker/Dockerfile b/docker/Dockerfile index b2b09129..258f90db 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -11,7 +11,7 @@ RUN set -x \ && buildDeps=" \ wget \ " \ - && apt-get update && apt-get install -y --no-install-recommends ${buildDeps} ${runtimeDeps} \ + && apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends ${buildDeps} ${runtimeDeps} \ && rm -rf /var/lib/apt/lists/* \ && wget --quiet -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-amd64" \ && echo "$GOSU_SHA256 /usr/local/bin/gosu" | sha256sum --check --status \ diff --git a/docs/_scripts/build_glossary.py b/docs/_scripts/build_glossary.py deleted file mode 100644 index 956da500..00000000 --- a/docs/_scripts/build_glossary.py +++ /dev/null @@ -1,54 +0,0 @@ -from pathlib import Path - -import mkdocs_gen_files -from mkdocs.structure.files import File, Files -from mkdocs.structure.pages import Page - -PAT = '{title} | {description}' - -config = mkdocs_gen_files.config - -docs_dir = config["docs_dir"] -glossary_dir = "glossary" -terms_dir = Path(docs_dir) / f"{glossary_dir}/terms" -index = "glossary/index.md" - -TABLE = [] -TABLE.append("# Glossary") -TABLE.append("") -TABLE.append("Term | Definition") -TABLE.append("-----|-----------") - -TERMS = {} - -for filename in terms_dir.iterdir(): - if filename.is_dir(): - continue - if filename.stem.startswith("."): - continue - fl = File(str(filename.relative_to(docs_dir)), config.docs_dir, config.site_dir, config.use_directory_urls) - pg = Page(None, fl, config) - pg.read_source(config) - pg.render(config, Files([])) - if pg.meta.get("template", "") != "term.html": - raise Exception(f"File {filename} does not have a template meta descriptor") - for t in pg.toc.items: - LINE = PAT.format( - id=filename.stem, - title=t.title, - url=f"{pg.url}{t.url}", - description=pg.meta.get("description", "").strip() or "< missing >", - ) - TERMS[t.title] = LINE - -for term in sorted(TERMS.keys()): - TABLE.append(TERMS[term]) - -with mkdocs_gen_files.open(index, "w") as f: - f.writelines("\n".join(TABLE)) -# -# with mkdocs_gen_files.open(index, "w") as f: -# for term in sorted(TERMS.keys()): -# f.write(f"{TERMS[term]}") - -mkdocs_gen_files.set_edit_path(index, "build_glossary.py") diff --git a/docs/_scripts/get_settings.py b/docs/_scripts/get_settings.py index 36591204..0efe3d26 100644 --- a/docs/_scripts/get_settings.py +++ b/docs/_scripts/get_settings.py @@ -1,38 +1,37 @@ -from io import StringIO - import mkdocs_gen_files -import requests - -MASK = """ -### {name} -*Type:* `{type}` +from hope_payment_gateway.config import env -*Default:* `{default}` - ------------ +MD_HEADER = """# Setttings """ -DEFAULTS = {} -TABLE = [] -TABLE.append("# Settings") -TABLE.append("") -TERMS = {} - -index = "guide-adm/hope/settings.md" +MD_LINE = """ +### {key} +_Default_: `{default_value}` -FILE = "https://raw.githubusercontent.com/unicef/hope/develop/backend/hct_mis_api/config/env.py" -res = requests.get(FILE) -buf = StringIO(res.text) -execCode = compile(res.text, "mulstring", "exec") -exec(execCode) -for k, v in DEFAULTS.items(): - TERMS[k] = MASK.format(name=k, type=v[0], default=v[1]) - -for term in sorted(TERMS.keys()): - TABLE.append(TERMS[term]) +{help} +""" +DEV_LINE = """ +__Suggested value for development__: `{develop_value}` +""" -with mkdocs_gen_files.open(index, "w") as f: - f.writelines("\n".join(TABLE)) -mkdocs_gen_files.set_edit_path(index, "build_glossary.py") +OUTFILE = "settings.md" +with mkdocs_gen_files.open(OUTFILE, "w") as f: + f.write(MD_HEADER) + for entry, cfg in sorted(env.config.items()): + f.write( + MD_LINE.format( + key=entry, default_value=cfg["default"], develop_value=env.get_develop_value(entry), help=cfg["help"] + ) + ) + if env.get_develop_value(entry): + f.write( + DEV_LINE.format( + key=entry, + default_value=cfg["default"], + develop_value=env.get_develop_value(entry), + help=cfg["help"], + ) + ) +mkdocs_gen_files.set_edit_path(OUTFILE, "get_settings.py")