diff --git a/docs/resources.rst b/docs/resources.rst index bcf11a2..9341951 100644 --- a/docs/resources.rst +++ b/docs/resources.rst @@ -20,7 +20,7 @@ ICCAD 2020 ~~~~~~~~~~ **Conference Dates:** 2nd November 2020 to 5th November 2020 - + * `https://iccad.com/event_details?id=305-8-D `__ WOSET 2020 @@ -108,3 +108,4 @@ Courses * `VLSI Systems Design course main page `__ * `Lab - Intro to OpenLane and Skywater 130 `__ + diff --git a/scripts/python-skywater-pdk/setup.py b/scripts/python-skywater-pdk/setup.py index 7b7029e..fed4c3b 100644 --- a/scripts/python-skywater-pdk/setup.py +++ b/scripts/python-skywater-pdk/setup.py @@ -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'], + }, ) diff --git a/scripts/python-skywater-pdk/skywater_pdk/generate-resources-rst.py b/scripts/python-skywater-pdk/skywater_pdk/generate-resources-rst.py index 9c1e7e8..2a34cfc 100644 --- a/scripts/python-skywater-pdk/skywater_pdk/generate-resources-rst.py +++ b/scripts/python-skywater-pdk/skywater_pdk/generate-resources-rst.py @@ -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 diff --git a/scripts/python-skywater-pdk/skywater_pdk/templates/__init__.py b/scripts/python-skywater-pdk/skywater_pdk/templates/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scripts/python-skywater-pdk/skywater_pdk/templates/resources.template.rst b/scripts/python-skywater-pdk/skywater_pdk/templates/resources.template.rst new file mode 100644 index 0000000..2fffe89 --- /dev/null +++ b/scripts/python-skywater-pdk/skywater_pdk/templates/resources.template.rst @@ -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 %} +