Skip to content

Commit

Permalink
最新チェックのフォーマットに合わせて挙動を調整
Browse files Browse the repository at this point in the history
  • Loading branch information
ma10 committed Jul 23, 2024
1 parent 6142996 commit 228836d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
18 changes: 11 additions & 7 deletions tools/yaml2x/a11y_guidelines/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,14 +923,18 @@ def get_dependency(self):
return uniq(dependency)

def example_template_data(self, lang):
template_data = {
'tool': self.id
}
example_objects = []
examples = {}
for example in self.examples:
example_objects.append(example.template_data(lang))
template_data['examples'] = sorted(example_objects, key=lambda item: item['check_id'])
return template_data
check_id = example.check_id
if check_id not in examples:
examples[check_id] = {
'check_id': check_id,
'check_text': example.check_text[lang],
'tool': self.id,
'procedures': []
}
examples[check_id]['procedures'].append(example.procedure.template_data(lang))
return sorted(examples.values(), key=lambda item: item['check_id'])

@classmethod
def list_all(cls):
Expand Down
18 changes: 10 additions & 8 deletions tools/yaml2x/yaml2rst/templates/checks/examples-tool.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,31 @@

{{ ex.check_text | indent(3) }}

.. _check-{{ ex.id }}:
{% for proc in ex.procedures -%}
.. _check-{{ proc.id }}:

{% filter make_heading(3, 'permalink') -%}
ID {{ ex.id }}
ID {{ proc.id }}
{%- endfilter %}

{{ ex.procedure }}
{% if ex.note is defined %}
{{ ex.note }}
{{ proc.procedure }}
{% if proc.note is defined %}
{{ proc.note }}
{% endif %}
{% if ex.YouTube is defined %}
{% if proc.YouTube is defined %}
{% if lang == 'ja' -%}
参考動画:
{%- elif lang == 'en' -%}
Reference Videos:
{%- endif %} `{{ ex.YouTube.title }} <https://www.youtube.com/watch?v={{ ex.YouTube.id }}>`__
{%- endif %} `{{ proc.YouTube.title }} <https://www.youtube.com/watch?v={{ proc.YouTube.id }}>`__

.. raw:: html

<iframe width="560" height="315" src="https://www.youtube.com/embed/{{ ex.YouTube.id }}" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/{{ proc.YouTube.id }}" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

{% endif %}
{% endfor %}
{% endfor %}
{% if lang == 'ja' -%}
.. translated:: true
{% endif %}
2 changes: 1 addition & 1 deletion tools/yaml2x/yaml2rst/yaml2rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get_allchecks(lang):

def get_example_pages(lang):
for tool in CheckTool.list_all():
yield {**tool.example_template_data(lang), **{'filename': f'examples-{tool.id}'}}
yield {**{'examples': tool.example_template_data(lang)}, **{'filename': f'examples-{tool.id}'}}

def get_faq_articles(lang):
for faq in Faq.list_all():
Expand Down

0 comments on commit 228836d

Please sign in to comment.