Skip to content
Binary file modified psi-document/sdrf-proteomics-specification-v1.1.0-dev.pdf
Binary file not shown.
35 changes: 27 additions & 8 deletions scripts/add-dev-banner.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
#!/bin/bash
# Add development version banner to documentation
# Add development version banner to all documentation pages
# Usage: ./add-dev-banner.sh <output_dir>

set -e

OUTPUT_DIR="${1:-docs}"

echo "Adding dev banner to: $OUTPUT_DIR"
echo "Adding dev banner to all HTML pages in: $OUTPUT_DIR"

# Add banner HTML to index.html
sed -i.bak 's/<body>/<body><div class="dev-banner">⚠️ Development Version - This documentation is from the dev branch and may contain unreleased changes. <a href="\/">View stable version<\/a><\/div>/' "$OUTPUT_DIR/index.html"
rm -f "$OUTPUT_DIR/index.html.bak"
# Use Python for reliable cross-platform HTML injection
python3 -c "
import os, re

# Append dev banner CSS to stylesheet
cat >> "$OUTPUT_DIR/css/style.css" << 'EOF'
output_dir = '$OUTPUT_DIR'
banner = '<div class=\"dev-banner\">&#9888;&#65039; Development Version - This documentation is from the dev branch and may contain unreleased changes. <a href=\"/\">View stable version</a></div>'
Comment on lines +12 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Don't splice OUTPUT_DIR into executable Python.

Line 15 turns the shell argument into part of the Python source. A valid path containing ' will break the script, and it also makes the injection step harder to reason about. Pass the directory via sys.argv or the environment instead.

Suggested change
-python3 -c "
-import os, re
+python3 - "$OUTPUT_DIR" <<'PY'
+import os, re, sys
 
-output_dir = '$OUTPUT_DIR'
+output_dir = sys.argv[1]
 banner = '<div class=\"dev-banner\">&#9888;&#65039; Development Version - This documentation is from the dev branch and may contain unreleased changes. <a href=\"/\">View stable version</a></div>'
@@
-"
+PY
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
python3 -c "
import os, re
# Append dev banner CSS to stylesheet
cat >> "$OUTPUT_DIR/css/style.css" << 'EOF'
output_dir = '$OUTPUT_DIR'
banner = '<div class=\"dev-banner\">&#9888;&#65039; Development Version - This documentation is from the dev branch and may contain unreleased changes. <a href=\"/\">View stable version</a></div>'
python3 - "$OUTPUT_DIR" <<'PY'
import os, re, sys
output_dir = sys.argv[1]
banner = '<div class=\"dev-banner\">&#9888;&#65039; Development Version - This documentation is from the dev branch and may contain unreleased changes. <a href=\"/\">View stable version</a></div>'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/add-dev-banner.sh` around lines 12 - 16, The script currently injects
the shell variable OUTPUT_DIR directly into the inline Python source (the
python3 -c invocation) by assigning it to the Python variable output_dir, which
is unsafe; instead pass the path via sys.argv or the environment: change the
python3 -c invocation so the Python code reads output_dir = sys.argv[1] (or
os.environ['OUTPUT_DIR']) and call python3 -c with the OUTPUT_DIR as a separate
argument (or export OUTPUT_DIR in the shell prior to invoking python), updating
any uses of output_dir and keeping the banner variable as-is (refer to
output_dir, banner, and the python3 -c invocation in the script).


for root, dirs, files in os.walk(output_dir):
for f in files:
if not f.endswith('.html'):
continue
path = os.path.join(root, f)
with open(path, 'r') as fh:
content = fh.read()
if 'dev-banner' in content:
continue
content = re.sub(r'(<body[^>]*>)', r'\1' + banner, content)
with open(path, 'w') as fh:
fh.write(content)
"

# Append dev banner CSS to stylesheet (only once)
if ! grep -q "dev-banner" "$OUTPUT_DIR/css/style.css" 2>/dev/null; then
cat >> "$OUTPUT_DIR/css/style.css" << 'EOF'

/* Dev banner */
.dev-banner {
Expand All @@ -29,5 +47,6 @@ cat >> "$OUTPUT_DIR/css/style.css" << 'EOF'
font-weight: 600;
}
EOF
fi

echo "Dev banner added successfully!"
echo "Dev banner added to all pages successfully!"
7 changes: 6 additions & 1 deletion scripts/build-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ cp site/sdrf-terms.html "$OUTPUT_DIR/"
cp site/quickstart.html "$OUTPUT_DIR/"
cp site/sdrf-explorer.html "$OUTPUT_DIR/"
cp site/sdrf-editor.html "$OUTPUT_DIR/"
cp site/sdrf-builder.html "$OUTPUT_DIR/"

# Copy SDRF terms TSV (if present) — also create TERMS.tsv alias for AsciiDoc links
cp sdrf-proteomics/metadata-guidelines/sdrf-terms.tsv "$OUTPUT_DIR/" 2>/dev/null || true
Expand All @@ -190,7 +191,11 @@ cp site/sdrf-data.json "$OUTPUT_DIR/"

# Inject navigation headers
echo "Adding navigation headers..."
python3 scripts/inject-headers.py "$OUTPUT_DIR"
if [ "$IS_DEV" = true ]; then
python3 scripts/inject-headers.py "$OUTPUT_DIR" --dev
else
python3 scripts/inject-headers.py "$OUTPUT_DIR"
fi

# Transform links (SDRF Explorer links and .adoc to .html)
echo "Transforming links..."
Expand Down
69 changes: 53 additions & 16 deletions scripts/inject-headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,82 +14,119 @@
from pathlib import Path


# Navigation header templates
# Version link placeholder — replaced at build time based on --dev flag
VERSION_LINK_PLACEHOLDER = '{{VERSION_LINK}}'

# Navigation header templates (use placeholder for version link)
HEADERS = {
'root': '''<header class="doc-header"><div class="doc-header-brand"><a href="./index.html">SDRF-Proteomics</a></div><nav class="doc-header-nav"><a href="./index.html">Home</a><a href="./specification.html" class="nav-current">Specification</a><a href="./index.html#metadata-guidelines">Metadata Guidelines</a><a href="./index.html#templates">Templates</a><a href="./index.html#tools">Tools</a><a href="./sdrf-explorer.html">Explorer</a><a href="./sdrf-editor.html">Editor</a><a href="./index.html#contributors">Contributors</a><a href="/dev/" class="version-link">Dev Version</a><a href="https://github.com/bigbio/proteomics-metadata-standard" target="_blank">GitHub</a></nav></header>''',
'root': f'''<header class="doc-header"><div class="doc-header-brand"><a href="./index.html">SDRF-Proteomics</a></div><nav class="doc-header-nav"><a href="./index.html">Home</a><a href="./specification.html" class="nav-current">Specification</a><a href="./index.html#metadata-guidelines">Metadata Guidelines</a><a href="./index.html#templates">Templates</a><a href="./index.html#tools">Tools</a><a href="./sdrf-explorer.html">Explorer</a><a href="./sdrf-editor.html">Editor</a><a href="./sdrf-builder.html">Template Builder</a><a href="./index.html#contributors">Contributors</a>{VERSION_LINK_PLACEHOLDER}<a href="https://github.com/bigbio/proteomics-metadata-standard" target="_blank">GitHub</a></nav></header>''',

'tools': '''<header class="doc-header"><div class="doc-header-brand"><a href="./index.html">SDRF-Proteomics</a></div><nav class="doc-header-nav"><a href="./index.html">Home</a><a href="./specification.html">Specification</a><a href="./index.html#metadata-guidelines">Metadata Guidelines</a><a href="./index.html#templates">Templates</a><a href="./index.html#tools" class="nav-current">Tools</a><a href="./sdrf-explorer.html">Explorer</a><a href="./sdrf-editor.html">Editor</a><a href="./index.html#contributors">Contributors</a><a href="/dev/" class="version-link">Dev Version</a><a href="https://github.com/bigbio/proteomics-metadata-standard" target="_blank">GitHub</a></nav></header>''',
'tools': f'''<header class="doc-header"><div class="doc-header-brand"><a href="./index.html">SDRF-Proteomics</a></div><nav class="doc-header-nav"><a href="./index.html">Home</a><a href="./specification.html">Specification</a><a href="./index.html#metadata-guidelines">Metadata Guidelines</a><a href="./index.html#templates">Templates</a><a href="./index.html#tools" class="nav-current">Tools</a><a href="./sdrf-explorer.html">Explorer</a><a href="./sdrf-editor.html">Editor</a><a href="./sdrf-builder.html">Template Builder</a><a href="./index.html#contributors">Contributors</a>{VERSION_LINK_PLACEHOLDER}<a href="https://github.com/bigbio/proteomics-metadata-standard" target="_blank">GitHub</a></nav></header>''',

'guidelines': '''<header class="doc-header"><div class="doc-header-brand"><a href="../index.html">SDRF-Proteomics</a></div><nav class="doc-header-nav"><a href="../index.html">Home</a><a href="../specification.html">Specification</a><a href="../index.html#metadata-guidelines" class="nav-current">Metadata Guidelines</a><a href="../index.html#templates">Templates</a><a href="../index.html#tools">Tools</a><a href="../sdrf-explorer.html">Explorer</a><a href="../sdrf-editor.html">Editor</a><a href="../index.html#contributors">Contributors</a><a href="/dev/" class="version-link">Dev Version</a><a href="https://github.com/bigbio/proteomics-metadata-standard" target="_blank">GitHub</a></nav></header>''',
'guidelines': f'''<header class="doc-header"><div class="doc-header-brand"><a href="../index.html">SDRF-Proteomics</a></div><nav class="doc-header-nav"><a href="../index.html">Home</a><a href="../specification.html">Specification</a><a href="../index.html#metadata-guidelines" class="nav-current">Metadata Guidelines</a><a href="../index.html#templates">Templates</a><a href="../index.html#tools">Tools</a><a href="../sdrf-explorer.html">Explorer</a><a href="../sdrf-editor.html">Editor</a><a href="../sdrf-builder.html">Template Builder</a><a href="../index.html#contributors">Contributors</a>{VERSION_LINK_PLACEHOLDER}<a href="https://github.com/bigbio/proteomics-metadata-standard" target="_blank">GitHub</a></nav></header>''',

'templates': '''<header class="doc-header"><div class="doc-header-brand"><a href="../index.html">SDRF-Proteomics</a></div><nav class="doc-header-nav"><a href="../index.html">Home</a><a href="../specification.html">Specification</a><a href="../index.html#metadata-guidelines">Metadata Guidelines</a><a href="../index.html#templates" class="nav-current">Templates</a><a href="../index.html#tools">Tools</a><a href="../sdrf-explorer.html">Explorer</a><a href="../sdrf-editor.html">Editor</a><a href="../index.html#contributors">Contributors</a><a href="/dev/" class="version-link">Dev Version</a><a href="https://github.com/bigbio/proteomics-metadata-standard" target="_blank">GitHub</a></nav></header>''',
'templates': f'''<header class="doc-header"><div class="doc-header-brand"><a href="../index.html">SDRF-Proteomics</a></div><nav class="doc-header-nav"><a href="../index.html">Home</a><a href="../specification.html">Specification</a><a href="../index.html#metadata-guidelines">Metadata Guidelines</a><a href="../index.html#templates" class="nav-current">Templates</a><a href="../index.html#tools">Tools</a><a href="../sdrf-explorer.html">Explorer</a><a href="../sdrf-editor.html">Editor</a><a href="../sdrf-builder.html">Template Builder</a><a href="../index.html#contributors">Contributors</a>{VERSION_LINK_PLACEHOLDER}<a href="https://github.com/bigbio/proteomics-metadata-standard" target="_blank">GitHub</a></nav></header>''',

'sample_guidelines': '''<header class="doc-header"><div class="doc-header-brand"><a href="./index.html">SDRF-Proteomics</a></div><nav class="doc-header-nav"><a href="./index.html">Home</a><a href="./specification.html">Specification</a><a href="./index.html#metadata-guidelines" class="nav-current">Metadata Guidelines</a><a href="./index.html#templates">Templates</a><a href="./index.html#tools">Tools</a><a href="./sdrf-explorer.html">Explorer</a><a href="./sdrf-editor.html">Editor</a><a href="./index.html#contributors">Contributors</a><a href="/dev/" class="version-link">Dev Version</a><a href="https://github.com/bigbio/proteomics-metadata-standard" target="_blank">GitHub</a></nav></header>''',
'sample_guidelines': f'''<header class="doc-header"><div class="doc-header-brand"><a href="./index.html">SDRF-Proteomics</a></div><nav class="doc-header-nav"><a href="./index.html">Home</a><a href="./specification.html">Specification</a><a href="./index.html#metadata-guidelines" class="nav-current">Metadata Guidelines</a><a href="./index.html#templates">Templates</a><a href="./index.html#tools">Tools</a><a href="./sdrf-explorer.html">Explorer</a><a href="./sdrf-editor.html">Editor</a><a href="./sdrf-builder.html">Template Builder</a><a href="./index.html#contributors">Contributors</a>{VERSION_LINK_PLACEHOLDER}<a href="https://github.com/bigbio/proteomics-metadata-standard" target="_blank">GitHub</a></nav></header>''',

'templates_guide': '''<header class="doc-header"><div class="doc-header-brand"><a href="./index.html">SDRF-Proteomics</a></div><nav class="doc-header-nav"><a href="./index.html">Home</a><a href="./specification.html">Specification</a><a href="./index.html#metadata-guidelines">Metadata Guidelines</a><a href="./index.html#templates" class="nav-current">Templates</a><a href="./index.html#tools">Tools</a><a href="./sdrf-explorer.html">Explorer</a><a href="./sdrf-editor.html">Editor</a><a href="./index.html#contributors">Contributors</a><a href="/dev/" class="version-link">Dev Version</a><a href="https://github.com/bigbio/proteomics-metadata-standard" target="_blank">GitHub</a></nav></header>'''
'templates_guide': f'''<header class="doc-header"><div class="doc-header-brand"><a href="./index.html">SDRF-Proteomics</a></div><nav class="doc-header-nav"><a href="./index.html">Home</a><a href="./specification.html">Specification</a><a href="./index.html#metadata-guidelines">Metadata Guidelines</a><a href="./index.html#templates" class="nav-current">Templates</a><a href="./index.html#tools">Tools</a><a href="./sdrf-explorer.html">Explorer</a><a href="./sdrf-editor.html">Editor</a><a href="./sdrf-builder.html">Template Builder</a><a href="./index.html#contributors">Contributors</a>{VERSION_LINK_PLACEHOLDER}<a href="https://github.com/bigbio/proteomics-metadata-standard" target="_blank">GitHub</a></nav></header>'''
}


def inject_header(filepath: str, header_html: str) -> None:
def inject_header(filepath: str, header_html: str, is_dev: bool = False) -> None:
"""Inject navigation header into an HTML file."""
with open(filepath, 'r', encoding='utf-8') as f:
content = f.read()

# Resolve version link based on dev/stable mode
if is_dev:
version_link = '<a href="/" class="version-link">Stable Version</a>'
else:
version_link = '<a href="/dev/" class="version-link">Dev Version</a>'
resolved_header = header_html.replace(VERSION_LINK_PLACEHOLDER, version_link)

# Add has-doc-header class to body
content = re.sub(r'<body class="([^"]*)"', r'<body class="has-doc-header \1"', content)
content = re.sub(r'<body>', '<body class="has-doc-header">', content)

# Insert header after opening body tag
content = re.sub(r'(<body[^>]*>)', r'\1\n' + header_html, content)
content = re.sub(r'(<body[^>]*>)', r'\1\n' + resolved_header, content)

with open(filepath, 'w', encoding='utf-8') as f:
f.write(content)


def rewrite_version_links(filepath: str, is_dev: bool) -> None:
"""Rewrite version links in static HTML pages (index.html, quickstart.html, etc.)."""
with open(filepath, 'r', encoding='utf-8') as f:
content = f.read()

if is_dev:
content = content.replace(
'<a href="/dev/" class="version-link">Dev Version</a>',
'<a href="/" class="version-link">Stable Version</a>'
)
# No change needed for stable — the source files already have /dev/ links

with open(filepath, 'w', encoding='utf-8') as f:
f.write(content)


def main():
if len(sys.argv) < 2:
print("Usage: python3 inject-headers.py <output_dir>")
print("Usage: python3 inject-headers.py <output_dir> [--dev]")
sys.exit(1)

is_dev = '--dev' in sys.argv
output_dir = Path(sys.argv[1])
Comment on lines 75 to 81
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

--dev is order-sensitive right now.

Line 81 always treats sys.argv[1] as the output directory, so python3 scripts/inject-headers.py --dev docs will try to operate on a directory literally named --dev. Please parse the CLI instead of relying on positional order.

Suggested change
+import argparse
 import sys
@@
 def main():
-    if len(sys.argv) < 2:
-        print("Usage: python3 inject-headers.py <output_dir> [--dev]")
-        sys.exit(1)
-
-    is_dev = '--dev' in sys.argv
-    output_dir = Path(sys.argv[1])
+    parser = argparse.ArgumentParser()
+    parser.add_argument("output_dir")
+    parser.add_argument("--dev", action="store_true")
+    args = parser.parse_args()
+
+    is_dev = args.dev
+    output_dir = Path(args.output_dir)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/inject-headers.py` around lines 75 - 81, The CLI currently assumes
sys.argv[1] is always the output directory which makes --dev order-sensitive;
update main() to robustly parse arguments by either using argparse or manually
scanning sys.argv to set is_dev (presence of '--dev') and assign output_dir to
the first non-flag argument instead of sys.argv[1]; modify the references to
is_dev and output_dir accordingly so commands like "inject-headers.py --dev
docs" and "inject-headers.py docs --dev" both work (refer to main, is_dev,
output_dir, and sys.argv in the diff).


print(f"Dev mode: {is_dev}")

# Inject header into specification.html
spec_file = output_dir / "specification.html"
if spec_file.exists():
print(f"Injecting header into: {spec_file}")
inject_header(str(spec_file), HEADERS['root'])
inject_header(str(spec_file), HEADERS['root'], is_dev)

# Inject header into tools.html
tools_file = output_dir / "tools.html"
if tools_file.exists():
print(f"Injecting header into: {tools_file}")
inject_header(str(tools_file), HEADERS['tools'])
inject_header(str(tools_file), HEADERS['tools'], is_dev)

# Inject header into sample-guidelines.html
sg_file = output_dir / "sample-guidelines.html"
if sg_file.exists():
print(f"Injecting header into: {sg_file}")
inject_header(str(sg_file), HEADERS['sample_guidelines'])
inject_header(str(sg_file), HEADERS['sample_guidelines'], is_dev)

# Inject header into templates.html (templates guide)
tpl_guide = output_dir / "templates.html"
if tpl_guide.exists():
print(f"Injecting header into: {tpl_guide}")
inject_header(str(tpl_guide), HEADERS['templates_guide'])
inject_header(str(tpl_guide), HEADERS['templates_guide'], is_dev)

# Inject headers into metadata-guidelines pages
guidelines_dir = output_dir / "metadata-guidelines"
if guidelines_dir.exists():
for html_file in guidelines_dir.glob("*.html"):
print(f"Injecting header into: {html_file}")
inject_header(str(html_file), HEADERS['guidelines'])
inject_header(str(html_file), HEADERS['guidelines'], is_dev)

# Inject headers into template pages
templates_dir = output_dir / "templates"
if templates_dir.exists():
for html_file in templates_dir.glob("*.html"):
print(f"Injecting header into: {html_file}")
inject_header(str(html_file), HEADERS['templates'])
inject_header(str(html_file), HEADERS['templates'], is_dev)

# Rewrite version links in static HTML pages (index.html, quickstart.html, etc.)
for static_page in ["index.html", "quickstart.html", "sdrf-terms.html",
"sdrf-explorer.html", "sdrf-editor.html", "sdrf-builder.html"]:
static_file = output_dir / static_page
if static_file.exists():
print(f"Rewriting version links in: {static_file}")
rewrite_version_links(str(static_file), is_dev)

print("Header injection complete!")

Expand Down
10 changes: 8 additions & 2 deletions site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<a href="#tools">Tools</a>
<a href="./sdrf-explorer.html">Explorer</a>
<a href="./sdrf-editor.html">Editor</a>
<a href="./sdrf-builder.html">Template Builder</a>
<a href="#contributors">Contributors</a>
<a href="/dev/" class="version-link">Dev Version</a>
<a href="https://github.com/bigbio/proteomics-metadata-standard" target="_blank">GitHub</a>
Expand Down Expand Up @@ -91,8 +92,13 @@ <h3>What does an SDRF file look like?</h3>
<section class="quick-links">
<div class="card">
<h3>Quick Start</h3>
<p>New to SDRF-Proteomics? Start here to learn the basics and create your first SDRF file.</p>
<a href="./quickstart.html">Get Started</a>
<p>New to SDRF-Proteomics? Learn the key concepts behind SDRF files and how to fill them in.</p>
<a href="./quickstart.html">Learn the Basics</a>
</div>
<div class="card">
<h3>Template Builder</h3>
<p>Build a customized SDRF template by selecting your technology, organism, and experiment type.</p>
<a href="./sdrf-builder.html">Build a Template</a>
</div>
<div class="card">
<h3>Validation</h3>
Expand Down
Loading