From 0232e0f992c3a03fe163b437cc1c1d631c8ddb83 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 11 Apr 2019 14:06:58 +0200 Subject: ee.bom: Moving it a single file, no need for more. --- src/ee/templates/bom.rst.j2 | 89 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 src/ee/templates/bom.rst.j2 (limited to 'src/ee/templates') diff --git a/src/ee/templates/bom.rst.j2 b/src/ee/templates/bom.rst.j2 new file mode 100644 index 0000000..3463d90 --- /dev/null +++ b/src/ee/templates/bom.rst.j2 @@ -0,0 +1,89 @@ +{% set bom_part_uri_idx = bom_parts.index("uri") -%} +BOM +=== + +{% if unresolved_parts %} +Unresolved parts: +{% for op in unresolved_parts %} +* `{{ op.ref }} `_ +{%- endfor %} +{%- endif %} + +Parts for BOM +=============== +{% for op in bom_parts %} +.. _ref-{{ op.ref }}: + +{{ op.ref | subsection }} +{% if op.available_from|length == 0 %} +Could not find part. + +{% if op.part.get_mpns()|length == 1 -%} +MPN: {{ op.part.get_mpns()[0].valueProp }} +{% elif op.part.get_mpns()|length > 1 -%} +{%- for mpn in op.part.get_mpns() %} +MPNs: +* {{ mpn.valueProp }} +{%- endfor %} +{%- endif -%} +{% if op.part.get_spns()|length == 1 -%} +SPN: {{ op.part.get_spns()[0].valueProp }} +{% elif op.part.get_spns()|length > 1 -%} +{%- for spn in op.part.get_spns() %} +SPNs: +* {{ spn.valueProp }} +{%- endfor %} +{%- endif -%} + +{% elif op.available_from|length == 1 %} +{%- set part=op.available_from.values()|first %} +{%- set pn=part|first_pn %} +{%- set spn=part|first_spn %} +Selected supplier: {{ part.supplier }}{{ (", pn: " + pn.valueProp) if pn else "" }}{{ (", spn: " + spn.valueProp) if spn else "" }}. +Part: `{{pn.valueProp}} `_ +{% else %} +MANY +{% endif %} +{%- endfor %} + +Part details +============ +{%- set part_by_uri=supplier_parts.index("uri") %} +{% for supplier, partUris in bom_parts.index("supplier,part").items() %} +{{ ("From " + supplier) | subsection }} +{% for partUri in partUris %} +{%- set part=part_by_uri.get_single(partUri) %} +{%- set pn=part|first_pn %} +{%- set spn=part|first_spn %} +{%- set title=pn.valueProp if pn else (spn.valueProp if spn else "???") %} +.. _part-{{title}}: + +{{ title|subsubsection }} + +=========== === +{%- if part.description %} +Description {{ part.description }} +{%- endif %} +MPN {{ pn.value }} +SPN {{ spn.value }} +Used by: {% for op in bom_part_uri_idx.get(part.uriProp) %}`{{ op.ref }} `_{{ ", " if not loop.last }}{% endfor %} +=========== === +{# +Facts +..... + +{% for f in part.facts.fact %} +f={{f}} +{% endfor %} + +#} +Documentation +............. + +{% for l in part.get_links() %} +{%- if l.relationProp == "http://purl.org/ee/link-relation#documentation" %} +* `{{ l.title }} <{{ l.url }}>`__ +{%- endif %} +{%- endfor %} +{% endfor %} +{% endfor %} -- cgit v1.2.3