Skip to content

Commit

Permalink
Merge pull request #437 from ma-bdi/master
Browse files Browse the repository at this point in the history
Multiversion and pdf features
  • Loading branch information
amattioc committed May 15, 2024
2 parents 202dd49 + 5fca2f7 commit 1a54d55
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 34 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/build-the-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
sudo apt-get update && sudo apt-get install graphviz -y
sudo apt-get update && sudo apt-get install graphviz texlive-font-utils -y
wget -O /tmp/plantuml-mit-1.2023.13.jar https://github.com/plantuml/plantuml/releases/download/v1.2023.13/plantuml-mit-1.2023.13.jar
- name: Sphynx build
run: |
sphinx-build -M html v2.1/docs outputdir
sphinx-build -M html v2.1/docs outputdir/2.1/
sphinx-build -b pdf v2.1/docs outputdir/2.1/html/pdf
cp index.html outputdir/
- name: Fix permissions
run: |
chmod -c -R +rX "outputdir/" | while read line; do
Expand All @@ -54,7 +56,7 @@ jobs:
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v2
with:
path: ./outputdir/html
path: ./outputdir

# Deployment job
deploy:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
venv
outputdir
*.jar
18 changes: 18 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SDMX TWG VTL DOCUMENTATION</title>
</head>

<body>
<ol>
<li><a href="https://sdmx.org/?page_id=5096">Version 2.0</a></li>
<li><a href="/vtl/2.1/html/">Version 2.1</a></li>
</ol>
</body>

</html>
80 changes: 49 additions & 31 deletions v2.1/docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
import os
import re
from pathlib import Path

from jinja2 import Environment, FileSystemLoader

VERSION = "2.1"


def name_norm(value):
return re.sub("[^a-zA-Z0-9]", "", value)


html_theme = "sphinx_rtd_theme"
extensions = [
"sphinxcontrib.mermaid",
"sphinxcontrib.plantuml",
"rst2pdf.pdfbuilder",
"sphinx_toolbox.collapse"
"sphinx_toolbox.collapse",
]
pdf_documents = [
("index", "rst2pdf", "Sample rst2pdf doc", "Your Name"),
("index", f"VTL_{VERSION}_DOCS", f"VTL {VERSION} DOCS", "SDMX-TWG"),
]
exclude_patterns = ["*intro.rst"]
exclude_patterns = ["*intro.rst", "pandocTranslation*"]
html_theme_options = {
"navigation_depth": 3,
"collapse_navigation": False,
Expand All @@ -26,42 +31,55 @@ def name_norm(value):
"github_user": "amattioc", # Username
"github_repo": "vtl", # Repo name
"github_version": "master", # Version
"conf_py_path": "/v2.1/docs/" # Path in the checkout to the docs root
"conf_py_path": f"/v{VERSION}/docs/", # Path in the checkout to the docs root
}

# Load templates
jinjaEnv = Environment(loader = FileSystemLoader(searchpath="templates"))
jinjaEnv.filters['name_norm'] = name_norm
jinjaEnv = Environment(loader=FileSystemLoader(searchpath="templates"))
jinjaEnv.filters["name_norm"] = name_norm
templates = {}
for template in next(os.walk("templates"))[2]:
templates[template] = jinjaEnv.get_template(template)

# Apply templates in each op type folder
for op_type in next(os.walk("operators"))[1]:
op_type_path = Path("operators").joinpath(op_type)
# Apply templates in each op folder
for op_folder in next(os.walk(op_type_path))[1]:
# Write the op main page
op_path = op_type_path.joinpath(op_folder)
with open(op_path.joinpath("index.rst"), "w") as f:
f.write(templates["operator"].render({"title": op_folder}))
op_type_path = Path("operators").joinpath(op_type)
# Apply templates in each op folder
for op_folder in next(os.walk(op_type_path))[1]:
# Write the op main page
op_path = op_type_path.joinpath(op_folder)
with open(op_path.joinpath("index.rst"), "w") as f:
f.write(templates["operator"].render({"title": op_folder}))

# Write the op examples
examples_folder = op_path.joinpath("examples")

ds_list = sorted(
x.with_suffix("").name for x in examples_folder.glob("ds_*.csv")
)
inputs = []
for i in range(len(ds_list)):
inputs.append({"folder": examples_folder, "i": i + 1, "name": ds_list[i]})

ex_list = sorted(
x.with_suffix("").name for x in examples_folder.glob("ex_*.vtl")
)
examples = []
for i in range(len(ex_list)):
examples.append({"folder": examples_folder, "i": i + 1, "name": ex_list[i]})

# Write the op examples
examples_folder = op_path.joinpath("examples")

ds_list = sorted(x.with_suffix('').name for x in examples_folder.glob("ds_*.csv"))
inputs = []
for i in range(len(ds_list)):
inputs.append({ "folder": examples_folder, "i": i + 1, "name": ds_list[i] })

ex_list = sorted(x.with_suffix('').name for x in examples_folder.glob("ex_*.vtl"))
examples = []
for i in range(len(ex_list)):
examples.append({ "folder": examples_folder, "i": i + 1, "name": ex_list[i] })

with open(op_path.joinpath("examples.rst"), "w") as f:
f.write(
templates["examples"].render({"examples": examples, "inputs": inputs, "op_type": op_type, "repourl_ex": "https://github.com/sdmx-twg/vtl/blob/master/v2.1/docs"})
)
with open(op_path.joinpath("examples.rst"), "w") as f:
f.write(
templates["examples"].render(
{
"examples": examples,
"inputs": inputs,
"op_type": op_type,
"repourl_ex": f"https://github.com/sdmx-twg/vtl/blob/master/v{VERSION}/docs",
}
)
)

plantuml = "java -jar " + os.getenv("PUML_PATH", "/tmp/plantuml-mit-1.2023.13.jar")
plantuml = (
"java -jar " + os.getenv("PUML_PATH", "/tmp/plantuml-mit-1.2023.13.jar") + " -tpng"
)
3 changes: 3 additions & 0 deletions v2.1/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ Documentation for VTL v2.1

user_manual
operators/index


`PDF Version <https://ma-bdi.github.io/vtl-twg/2.1/html/pdf/VTL_2.1_DOCS.pdf>`_

0 comments on commit 1a54d55

Please sign in to comment.