Skip to content
Open
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
53 changes: 44 additions & 9 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,55 @@ def build_served_html():
from pathlib import Path

os.chdir(Path(__file__).parent)
versions = [

# Create .htaccess to serve schemas inline (not download)
os.makedirs("_html_extra", exist_ok=True)
htaccess_content = """<FilesMatch "\\.schema$">
Header set Content-Disposition "inline"
</FilesMatch>
"""
with open("_html_extra/.htaccess", "w") as f:
f.write(htaccess_content)
print(f"✅ Created .htaccess to serve schemas inline")

# Fetch GitHub tags and download schemas
try:
result = subprocess.check_output([
"git", "ls-remote", "--tags", "https://github.com/ome/ngff-spec"
], text=True, timeout=10)
tags = [line.split()[1].replace("refs/tags/", "").rstrip("^{}") for line in result.strip().split("\n") if line]
for tag in sorted(set(tags)):
schema_dir = f"_html_extra/{tag}/schemas"
os.makedirs(schema_dir, exist_ok=True)
# Download schemas from GitHub raw for this tag
gh_url = f"https://github.com/ome/ngff-spec/archive/refs/tags/{tag}.tar.gz"
try:
import tempfile, tarfile
with tempfile.NamedTemporaryFile(delete=False) as tmp:
subprocess.check_call(["curl", "-sL", gh_url, "-o", tmp.name])
with tarfile.open(tmp.name) as tar:
for member in tar.getmembers():
if "/schemas/" in member.name and member.name.endswith(".schema"):
# Extract just the filename, flatten into schema_dir
target = os.path.join(schema_dir, os.path.basename(member.name))
tar.extract(member, path=tempfile.gettempdir())
src = os.path.join(tempfile.gettempdir(), member.name)
shutil.copy2(src, target)
os.unlink(tmp.name)
print(f"✅ Downloaded schemas for {tag}")
except Exception as e:
print(f"⚠️ Could not download schemas for {tag}: {e}")
except Exception:
pass

# Build specifications from local submodules
displayed_spec_versions = [
d
for d in os.listdir("specifications")
if os.path.isdir(os.path.join("specifications", d))
]

for version in versions:

# copy schemas to _html_extra
os.makedirs(f"_html_extra/{version}/schemas", exist_ok=True)
schemas = glob.glob(f"specifications/{version}/**/*.schema", recursive=True)
for schema in schemas:
shutil.copy2(schema, f"_html_extra/{version}/schemas/")
print(f"✅ Copied schemas for version {version}")
for version in displayed_spec_versions:

# find 'pre_build.py' in 'specifications' subdirectories
script = glob.glob(f"specifications/{version}/**/pre_build.py", recursive=True)[
Expand Down
Loading