generate-resources: moved the RST template to a separate file

Signed-off-by: Grzegorz Latosinski <glatosinski@antmicro.com>
This commit is contained in:
Grzegorz Latosinski 2020-12-01 11:43:42 +01:00
parent 5a151a7f76
commit c4ed34efb0
5 changed files with 122 additions and 109 deletions

View File

@ -20,7 +20,7 @@ ICCAD 2020
~~~~~~~~~~
**Conference Dates:** 2nd November 2020 to 5th November 2020
* `https://iccad.com/event_details?id=305-8-D <https://iccad.com/event_details?id=305-8-D>`__
WOSET 2020
@ -108,3 +108,4 @@ Courses
* `VLSI Systems Design course main page <https://inst.eecs.berkeley.edu/~cs250/fa20/>`__
* `Lab - Intro to OpenLane and Skywater 130 <https://inst.eecs.berkeley.edu/~cs250/fa20/labs/lab1/>`__

View File

@ -70,4 +70,8 @@ setup(
'Bug Reports': 'https://github.com/google/skywater-pdk/issues',
'Source': 'https://github.com/google/skywater-pdk/',
},
package_data = {
'skywater_pdk': ['templates/resources.template.rst'],
},
)

View File

@ -18,111 +18,17 @@
# SPDX-License-Identifier: Apache-2.0
import sys
import os
import argparse
from pathlib import Path
import pandas as pd
import errno
from jinja2 import Template
import importlib.resources as resources
sys.path.insert(0, os.path.abspath(__file__ + '../'))
resources_rst_template = """Further Resources
=================
News Articles
-------------
{% for _, row in news_articles.iterrows() -%}
* `{{ row["Article"] }} <{{ row["Link"] }}>`__
{% endfor %}
Conferences
-----------
{% for _, row in conferences.iterrows() -%}
{% if row["Conference"] %}
{{ row["Conference"] }}
{{ '~' * row["Conference"]|length }}
{% endif -%}
{% if row["Description"] -%}
{{ row["Description"] }}
{% endif -%}
{% if row["Related link"] -%}
* `{{ row["Related link"] }} <{{ row["Related link"] }}>`__
{% endif -%}
{% endfor %}
Talk Series
-----------
{% for _, row in talk_series.iterrows() -%}
{% if row["Talk series"] %}
{{ row["Talk series"] }}
{{ '~' * row["Talk series"]|length }}
{% if row["Description"] %}
{{ row["Description"] }}
{% endif -%}
{% if row["Page"] %}
**Page**: {{ row["Page"] }}
{% endif -%}
{% endif %}
{{ row["Title"] }}
{{ '^' * row["Title"]|length }}
{% if row["Presenter"] -%}
**Presenter**: {{ row["Presenter"] }}
{% endif -%}
{% if row["Talk details"] -%}
**Details**: {{ row["Talk details"] }}
{% endif -%}
{% if row["Video link"] -%}
{% if row["Video"] -%}
**Video**: `{{ row["Video"] }} <{{ row["Video link"] }}>`__
{% else -%}
**Video**: `{{ row["Video link"] }} <{{ row["Video link"] }}>`__
{% endif -%}
{% endif -%}
{% if row["Slides PPTX link"] -%}
{% if row["Slides PPTX"] -%}
**Video**: `{{ row["Slides PPTX"] }} <{{ row["Slides PPTX link"] }}>`__
{% else -%}
**Video**: `{{ row["Slides PPTX link"] }} <{{ row["Slides PPTX link"] }}>`__
{% endif -%}
{% endif -%}
{% if row["Slides PDF link"] -%}
{% if row["Slides PDF"] -%}
**Video**: `{{ row["Slides PDF"] }} <{{ row["Slides PDF link"] }}>`__
{% else -%}
**Video**: `{{ row["Slides PDF link"] }} <{{ row["Slides PDF link"] }}>`__
{% endif -%}
{% endif -%}
{% endfor %}
LinkedIn Posts
--------------
{% for _, row in linkedin.iterrows() -%}
* `{{ row["Title"] }} <{{ row["Link"] }}>`__
{% endfor %}
Courses
-------
{% for _, row in courses.iterrows() -%}
{% if row["Courses"] %}
{{ row["Courses"] }}
{{ '~' * row["Courses"]|length }}
{% endif -%}
{% if row["Link"] -%}
{% if row["Link title"] -%}
* `{{ row["Link title"] }} <{{ row["Link"] }}>`__
{% else -%}
* `{{ row["Link"] }} <{{ row["Link"] }}>`__
{% endif -%}
{% endif -%}
{% endfor %}
"""
from skywater_pdk import templates
def parse_entries(filepath, sheet_name, cols=None):
@ -183,17 +89,21 @@ def main(argv):
linkedin = parse_entries(input_file, 'LinkedIn Posts')
courses = parse_entries(input_file, 'Courses')
tm = Template(resources_rst_template)
resources_rst_content = tm.render(
news_articles=news_articles,
talk_series=talk_series,
conferences=conferences,
linkedin=linkedin,
courses=courses
)
with resources.path(templates, 'resources.template.rst') as resourcepath:
with open(resourcepath, 'r') as resourcetemplate:
resources_rst_template = resourcetemplate.read()
with open(args.output, 'w') as out:
out.write(resources_rst_content)
tm = Template(resources_rst_template)
resources_rst_content = tm.render(
news_articles=news_articles,
talk_series=talk_series,
conferences=conferences,
linkedin=linkedin,
courses=courses
)
with open(args.output, 'w') as out:
out.write(resources_rst_content)
return 0

View File

@ -0,0 +1,98 @@
Further Resources
=================
News Articles
-------------
{% for _, row in news_articles.iterrows() -%}
* `{{ row["Article"] }} <{{ row["Link"] }}>`__
{% endfor %}
Conferences
-----------
{% for _, row in conferences.iterrows() -%}
{% if row["Conference"] %}
{{ row["Conference"] }}
{{ '~' * row["Conference"]|length }}
{% endif -%}
{% if row["Description"] -%}
{{ row["Description"] }}
{% endif -%}
{% if row["Related link"] -%}
* `{{ row["Related link"] }} <{{ row["Related link"] }}>`__
{% endif -%}
{% endfor %}
Talk Series
-----------
{% for _, row in talk_series.iterrows() -%}
{% if row["Talk series"] %}
{{ row["Talk series"] }}
{{ '~' * row["Talk series"]|length }}
{% if row["Description"] %}
{{ row["Description"] }}
{% endif -%}
{% if row["Page"] %}
**Page**: {{ row["Page"] }}
{% endif -%}
{% endif %}
{{ row["Title"] }}
{{ '^' * row["Title"]|length }}
{% if row["Presenter"] -%}
**Presenter**: {{ row["Presenter"] }}
{% endif -%}
{% if row["Talk details"] -%}
**Details**: {{ row["Talk details"] }}
{% endif -%}
{% if row["Video link"] -%}
{% if row["Video"] -%}
**Video**: `{{ row["Video"] }} <{{ row["Video link"] }}>`__
{% else -%}
**Video**: `{{ row["Video link"] }} <{{ row["Video link"] }}>`__
{% endif -%}
{% endif -%}
{% if row["Slides PPTX link"] -%}
{% if row["Slides PPTX"] -%}
**Video**: `{{ row["Slides PPTX"] }} <{{ row["Slides PPTX link"] }}>`__
{% else -%}
**Video**: `{{ row["Slides PPTX link"] }} <{{ row["Slides PPTX link"] }}>`__
{% endif -%}
{% endif -%}
{% if row["Slides PDF link"] -%}
{% if row["Slides PDF"] -%}
**Video**: `{{ row["Slides PDF"] }} <{{ row["Slides PDF link"] }}>`__
{% else -%}
**Video**: `{{ row["Slides PDF link"] }} <{{ row["Slides PDF link"] }}>`__
{% endif -%}
{% endif -%}
{% endfor %}
LinkedIn Posts
--------------
{% for _, row in linkedin.iterrows() -%}
* `{{ row["Title"] }} <{{ row["Link"] }}>`__
{% endfor %}
Courses
-------
{% for _, row in courses.iterrows() -%}
{% if row["Courses"] %}
{{ row["Courses"] }}
{{ '~' * row["Courses"]|length }}
{% endif -%}
{% if row["Link"] -%}
{% if row["Link title"] -%}
* `{{ row["Link title"] }} <{{ row["Link"] }}>`__
{% else -%}
* `{{ row["Link"] }} <{{ row["Link"] }}>`__
{% endif -%}
{% endif -%}
{% endfor %}