Skip to content

Commit

Permalink
changes to 300 HTML script and document SOTD macro
Browse files Browse the repository at this point in the history
- in 300 HTML generation script, the generation of guides can now be
  manually controlled by using the -G/--guides flag
- in the macro for dpv document family, the SOTD section has a new
  parameter to override the 'draft' checking for cases such as guides
  which don't have any metadata indicating their draft status
  • Loading branch information
coolharsh55 committed Aug 16, 2024
1 parent b5dd89c commit 92b83f1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
51 changes: 34 additions & 17 deletions code/300_generate_HTML.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,22 +896,6 @@ def _write_template(

INFO('*'*40)

# INFO('Generating GUIDES')

# for doc, data in GUIDES.items():
# DEBUG(f'generating guide: {doc}')
# template = data['template']
# filepath = f"{data['output']}"
# with open(filepath, 'w') as fd:
# template = template_env.get_template(template)
# fd.write(template.render(DPV_VERSION=DPV_VERSION, DOCUMENT_STATUS=DOCUMENT_STATUS))
# INFO(f"wrote guide {doc} at {filepath}")
# with open('../guides/index.html', 'w') as fd:
# template = template_env.get_template('template_guides_index.jinja2')
# fd.write(template.render(DPV_VERSION=DPV_VERSION, DOCUMENT_STATUS=DOCUMENT_STATUS))
# INFO(f"wrote guide {doc} at {filepath}")
# INFO('*'*40)

INFO('Generating Search Index')
results_classes = list(DATA.graph.query("""
SELECT
Expand Down Expand Up @@ -1004,4 +988,37 @@ def add_item_to_index(iri):
DPV_VERSION=DPV_VERSION))
INFO(f"wrote search index document at {filepath}")

INFO('*'*40)
INFO('*'*40)

# == script ==
if __name__ == '__main__':
# The script has a default behaviour where it will NOT download
# any file and will extract ALL CSVs from existing files.
import argparse
parser = argparse.ArgumentParser()
# - `-d` will download and extract ALL files
parser.add_argument('-G', '--guides', action='store_true', help="generate guides")
# - `-x` will extract ALL files
# parser.add_argument('-x', '--x', action='store_true', default=True, help="extract CSVs from all data files")
# # - `-ds <foo>` will download and extract ONLY `foo` files
# parser.add_argument('--ds', nargs='+', default=False, help="download only indicated data files")
# # - `-xs <foo>` will extract ONLY `foo` files
# parser.add_argument('--xs', nargs='+', default=False, help="extract CSVs from indicated data files")
args = parser.parse_args()

# If files are to be downloaded, do the following.
if args.guides:
INFO('Generating GUIDES')
for doc, data in GUIDES.items():
DEBUG(f'generating guide: {doc}')
template = data['template']
filepath = f"{data['output']}"
with open(filepath, 'w') as fd:
template = template_env.get_template(template)
fd.write(template.render(DPV_VERSION=DPV_VERSION, DOCUMENT_STATUS=DOCUMENT_STATUS))
INFO(f"wrote guide {doc} at {filepath}")
with open('../guides/index.html', 'w') as fd:
template = template_env.get_template('template_guides_index.jinja2')
fd.write(template.render(DPV_VERSION=DPV_VERSION, DOCUMENT_STATUS=DOCUMENT_STATUS))
INFO(f"wrote guide {doc} at {filepath}")
INFO('*'*40)
4 changes: 2 additions & 2 deletions code/jinja2_resources/macro_dpv_document_family.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
</section>
{% endmacro %}

{% macro sotd(metadata=None) %}
{% macro sotd(metadata=None, draft=True) %}
<section id="sotd">
{% if metadata %}
{% if 'published' not in metadata['bibo:status'] %}
{% if 'published' not in metadata['bibo:status'] and draft == True %}
<aside class="note" title="WARNING" style="color: red;">
<p>This vocabulary is currently in draft form, and may undergo major changes.</p>
</aside>
Expand Down

0 comments on commit 92b83f1

Please sign in to comment.