diff --git a/build_docs.py b/build_docs.py index 2e266d4..4602f8c 100644 --- a/build_docs.py +++ b/build_docs.py @@ -766,6 +766,19 @@ def read_file(path): return "" +def get_hemlock_version(): + """Read the Hemlock version from the submodule's version.h header.""" + version_h = HEMLOCK_DIR / 'include' / 'version.h' + try: + content = read_file(version_h) + match = re.search(r'#define\s+HEMLOCK_VERSION\s+"([^"]+)"', content) + if match: + return match.group(1) + except Exception as e: + print(f"Warning: Could not read version from {version_h}: {e}") + return None + + def get_translated_path(original_path, lang): """Get the translated file path if it exists, otherwise return the original.""" if lang == 'en': @@ -1109,6 +1122,10 @@ def generate_html(docs, logo_data, lang='en'): } page_title = titles.get(lang, titles['en']) + # Read version from hemlock submodule + hemlock_version = get_hemlock_version() + version_badge_html = f'v{hemlock_version}' if hemlock_version else '' + # Generate language switcher options lang_options = [] for code, name in SUPPORTED_LANGUAGES.items(): @@ -1234,6 +1251,20 @@ def generate_html(docs, logo_data, lang='en'): margin-right: auto; }} + .version-badge {{ + display: inline-block; + background: rgba(255,255,255,0.15); + color: #E8F4E1; + font-size: 0.75rem; + font-weight: 500; + padding: 0.15em 0.55em; + border-radius: 4px; + margin-left: 0.6rem; + vertical-align: middle; + letter-spacing: 0.3px; + border: 1px solid rgba(255,255,255,0.2); + }} + @media (max-width: 1023px) {{ .header {{ justify-content: flex-start; @@ -1864,7 +1895,7 @@ def generate_html(docs, logo_data, lang='en'):