From d1cdb7bdb8fecec9be4e5921e240b7ca08e711e3 Mon Sep 17 00:00:00 2001 From: Masafumi NAKANE Date: Fri, 29 Mar 2024 14:11:57 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=E7=84=A1=E9=A7=84=E3=81=AA=E7=A9=BA?= =?UTF-8?q?=E8=A1=8C=E3=81=AE=E5=87=BA=E5=8A=9B=E6=8A=91=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/yaml2rst/templates/en/faq/article.rst | 20 ++++++++------------ tools/yaml2rst/templates/ja/faq/article.rst | 21 ++++++++------------- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/tools/yaml2rst/templates/en/faq/article.rst b/tools/yaml2rst/templates/en/faq/article.rst index 7cb0b577..8eeb680f 100644 --- a/tools/yaml2rst/templates/en/faq/article.rst +++ b/tools/yaml2rst/templates/en/faq/article.rst @@ -26,19 +26,17 @@ Explanation {%- endfilter %} {{ explanation }} - -{% if guidelines is defined -%} -{%- filter make_heading(2) -%} +{% if guidelines is defined %} +{% filter make_heading(2) -%} Related Guidelines {%- endfilter %} {% for gl in guidelines -%} * {{ gl.category }}: :ref:`{{ gl.guideline }}` {% endfor %} -{%- endif %} - -{% if checks is defined -%} -{%- filter make_heading(2) -%} +{%- endif -%} +{% if checks is defined %} +{% filter make_heading(2) -%} Related Checklist Items {%- endfilter %} @@ -46,10 +44,9 @@ Related Checklist Items :ref:`check-{{ check.id }}` {{ check.check | indent(3) }} {% endfor %} -{%- endif %} - -{% if info is defined -%} -{%- filter make_heading(2) -%} +{%- endif -%} +{% if info is defined %} +{% filter make_heading(2) -%} Related Supplementary Information {%- endfilter %} @@ -57,4 +54,3 @@ Related Supplementary Information * {{ i }} {% endfor %} {%- endif %} - diff --git a/tools/yaml2rst/templates/ja/faq/article.rst b/tools/yaml2rst/templates/ja/faq/article.rst index daa83254..48f1c306 100644 --- a/tools/yaml2rst/templates/ja/faq/article.rst +++ b/tools/yaml2rst/templates/ja/faq/article.rst @@ -27,18 +27,17 @@ {{ explanation }} -{% if guidelines is defined -%} -{%- filter make_heading(2) -%} +{% if guidelines is defined %} +{% filter make_heading(2) -%} 関連ガイドライン項目 {%- endfilter %} {% for gl in guidelines -%} * {{ gl.category }}: :ref:`{{ gl.guideline }}` {% endfor %} -{%- endif %} - -{% if checks is defined -%} -{%- filter make_heading(2) -%} +{%- endif -%} +{% if checks is defined %} +{% filter make_heading(2) -%} 関連チェック内容 {%- endfilter %} @@ -46,10 +45,9 @@ :ref:`check-{{ check.id }}` {{ check.check | indent(3) }} {% endfor %} -{%- endif %} - -{% if info is defined -%} -{%- filter make_heading(2) -%} +{%- endif -%} +{% if info is defined %} +{% filter make_heading(2) -%} 関連する参考情報 {%- endfilter %} @@ -57,7 +55,4 @@ * {{ i }} {% endfor %} {%- endif %} - - .. translated:: true - From 873a96553a0877b12f0c69981ab76a31bcc8f0ff Mon Sep 17 00:00:00 2001 From: Masafumi NAKANE Date: Fri, 29 Mar 2024 14:16:24 +0900 Subject: [PATCH 2/5] =?UTF-8?q?=E3=83=86=E3=83=B3=E3=83=97=E3=83=AC?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=83=BB=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=81=AB=E5=AF=BE=E3=81=97=E3=81=A6=E3=81=AFsphinx-lint?= =?UTF-8?q?=E3=81=AF=E5=AE=9F=E8=A1=8C=E3=81=97=E3=81=AA=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .lintstagedrc.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.lintstagedrc.mjs b/.lintstagedrc.mjs index 692eced3..471d16c2 100644 --- a/.lintstagedrc.mjs +++ b/.lintstagedrc.mjs @@ -4,5 +4,5 @@ export default { 'data/yaml/gl/**/*.yaml': (files) => files.map((file) => `ajv validate --spec=draft2020 -s data/json/schemas/guideline.json -r data/json/schemas/common.json -d ${file}`), 'data/yaml/checks/**/*.yaml': (files) => files.map((file) => `ajv validate --spec=draft2020 -s data/json/schemas/check.json -r data/json/schemas/common.json -d ${file}`), 'data/yaml/faq/**/*.yaml': (files) => files.map((file) => `ajv validate --spec=draft2020 -s data/json/schemas/faq.json -r data/json/schemas/common.json -d ${file}`), - '*.rst': 'sphinx-lint --enable all --disable line-too-long', + '(ja|en)/**/*.rst': 'sphinx-lint --enable all --disable line-too-long', } From 17151dad3cc04677582cba72b80ee48645c1f7a1 Mon Sep 17 00:00:00 2001 From: Masafumi NAKANE Date: Fri, 29 Mar 2024 14:25:49 +0900 Subject: [PATCH 3/5] =?UTF-8?q?FAQ=E3=81=AE=E3=82=B9=E3=82=AD=E3=83=BC?= =?UTF-8?q?=E3=83=9E=E3=81=AB=E9=96=A2=E9=80=A3FAQ=E3=81=AE=E3=83=95?= =?UTF-8?q?=E3=82=A3=E3=83=BC=E3=83=AB=E3=83=89=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/json/schemas/faq.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/data/json/schemas/faq.json b/data/json/schemas/faq.json index 4724852b..2d2a5695 100644 --- a/data/json/schemas/faq.json +++ b/data/json/schemas/faq.json @@ -68,6 +68,14 @@ "items": { "type": "string" } + }, + "faqs": { + "description": "related FAQ entry if any", + "type": "array", + "minItems": 1, + "items": { + "type": "string" + } } }, "additionalProperties": false, From 7ce38090db13f41b15ff01a428a53834a786aa6b Mon Sep 17 00:00:00 2001 From: Masafumi NAKANE Date: Fri, 29 Mar 2024 14:27:32 +0900 Subject: [PATCH 4/5] =?UTF-8?q?FAQ=E3=81=AE=E9=96=A2=E9=80=A3FAQ=E3=83=95?= =?UTF-8?q?=E3=82=A3=E3=83=BC=E3=83=AB=E3=83=89=E3=81=AE=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/yaml2rst/a11y_guidelines.py | 34 ++++++++++++++++++- tools/yaml2rst/a11y_guidelines_initializer.py | 4 ++- tools/yaml2rst/templates/en/faq/article.rst | 9 +++++ tools/yaml2rst/templates/ja/faq/article.rst | 8 +++++ 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/tools/yaml2rst/a11y_guidelines.py b/tools/yaml2rst/a11y_guidelines.py index 8756175a..b067bb96 100644 --- a/tools/yaml2rst/a11y_guidelines.py +++ b/tools/yaml2rst/a11y_guidelines.py @@ -16,6 +16,7 @@ def __init__(self): if self._initialized: return self._data = {} + self._unresolved_faqs = {} self._initialized = True def associate_objects(self, obj1, obj2): @@ -41,6 +42,23 @@ def associate_objects(self, obj1, obj2): if obj1 not in self._data[obj2_type][obj2_id][obj1_type]: self._data[obj2_type][obj2_id][obj1_type].append(obj1) + def add_unresolved_faqs(self, faq1, faq2): + if faq1 not in self._unresolved_faqs: + self._unresolved_faqs[faq1] = [] + if faq2 not in self._unresolved_faqs[faq1]: + self._unresolved_faqs[faq1].append(faq2) + if faq2 not in self._unresolved_faqs: + self._unresolved_faqs[faq2] = [] + if faq1 not in self._unresolved_faqs[faq2]: + self._unresolved_faqs[faq2].append(faq1) + + def resolve_faqs(self): + for faq_id in self._unresolved_faqs: + for faq2_id in self._unresolved_faqs[faq_id]: + faq1 = Faq.get_by_id(faq_id) + faq2 = Faq.get_by_id(faq2_id) + self.associate_objects(faq1, faq2) + def get_guidelines_to_category(self): mapping = {} for category in self._data['category']: @@ -119,6 +137,11 @@ def get_info_to_faqs(self, info): return self._data['info_ref'][info.id]['faq'] return [] + def get_related_faqs(self, faq): + if faq.id not in self._unresolved_faqs: + return [] + return sorted(self._data['faq'][faq.id]['faq'], key=lambda item: item.sort_key) + def get_axe_to_wcagsc(self, axe_rule): if 'wcag_sc' in self._data['axe_rule'][axe_rule.id]: return self._data['axe_rule'][axe_rule.id]['wcag_sc'] @@ -304,7 +327,9 @@ def __init__(self, faq): if 'info' in faq: for info in faq['info']: rel.associate_objects(self, InfoRef(info)) - + if 'faqs' in faq: + for related_faq in faq['faqs']: + rel.add_unresolved_faqs(self.id, related_faq) Faq.all_faqs[self.id] = self def get_dependency(self): @@ -344,6 +369,9 @@ def template_object(self, lang): info = rel.get_faq_to_info(self) if len(info): template_object['info'] = [inforef.refstring() for inforef in info] + related_faqs = rel.get_related_faqs(self) + if len(related_faqs) > 0: + template_object['related_faqs'] = [faq.id for faq in related_faqs] return template_object @classmethod @@ -358,6 +386,10 @@ def list_all_src_paths(cls): for faq in cls.all_faqs.values(): yield faq.src_path + @classmethod + def get_by_id(cls, faq_id): + return cls.all_faqs.get(faq_id) + class Category: all_categories = {} diff --git a/tools/yaml2rst/a11y_guidelines_initializer.py b/tools/yaml2rst/a11y_guidelines_initializer.py index 9e7df27b..b2e18687 100644 --- a/tools/yaml2rst/a11y_guidelines_initializer.py +++ b/tools/yaml2rst/a11y_guidelines_initializer.py @@ -45,7 +45,9 @@ def setup_instances(settings): process_axe_rules(src_path['axe_rules'], src_path['axe_msg_ja'], src_path['axe_pkg'], DEQUE_URL) - return RelationshipManager() + rel = RelationshipManager() + rel.resolve_faqs() + return rel def process_axe_rules(axe_rules_dir, axe_msg_ja_file, axe_pkg_file, base_url): try: diff --git a/tools/yaml2rst/templates/en/faq/article.rst b/tools/yaml2rst/templates/en/faq/article.rst index 8eeb680f..ff31bc04 100644 --- a/tools/yaml2rst/templates/en/faq/article.rst +++ b/tools/yaml2rst/templates/en/faq/article.rst @@ -26,6 +26,15 @@ Explanation {%- endfilter %} {{ explanation }} +{% if related_faqs is defined %} +{% filter make_heading(2) -%} +Related FAQs +{%- endfilter %} + +{% for faq in related_faqs -%} +* :ref:`faq-{{ faq }}` +{% endfor %} +{%- endif -%} {% if guidelines is defined %} {% filter make_heading(2) -%} Related Guidelines diff --git a/tools/yaml2rst/templates/ja/faq/article.rst b/tools/yaml2rst/templates/ja/faq/article.rst index 48f1c306..305f63d0 100644 --- a/tools/yaml2rst/templates/ja/faq/article.rst +++ b/tools/yaml2rst/templates/ja/faq/article.rst @@ -26,7 +26,15 @@ {%- endfilter %} {{ explanation }} +{% if related_faqs is defined %} +{% filter make_heading(2) -%} +関連FAQ +{%- endfilter %} +{% for faq in related_faqs -%} +* :ref:`faq-{{ faq }}` +{% endfor %} +{%- endif -%} {% if guidelines is defined %} {% filter make_heading(2) -%} 関連ガイドライン項目 From 5f1a9c0fb916b75eaaec00885eb5af4708225799 Mon Sep 17 00:00:00 2001 From: Masafumi NAKANE Date: Fri, 29 Mar 2024 14:49:41 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=E3=83=86=E3=83=B3=E3=83=97=E3=83=AC?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=81=AE=E6=9C=80=E5=BE=8C=E3=81=ABnewline?= =?UTF-8?q?=E3=81=8C=E5=BF=85=E8=A6=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/yaml2rst/templates/en/faq/article.rst | 1 + tools/yaml2rst/templates/ja/faq/article.rst | 1 + 2 files changed, 2 insertions(+) diff --git a/tools/yaml2rst/templates/en/faq/article.rst b/tools/yaml2rst/templates/en/faq/article.rst index ff31bc04..03b09c82 100644 --- a/tools/yaml2rst/templates/en/faq/article.rst +++ b/tools/yaml2rst/templates/en/faq/article.rst @@ -63,3 +63,4 @@ Related Supplementary Information * {{ i }} {% endfor %} {%- endif %} + diff --git a/tools/yaml2rst/templates/ja/faq/article.rst b/tools/yaml2rst/templates/ja/faq/article.rst index 305f63d0..1b854775 100644 --- a/tools/yaml2rst/templates/ja/faq/article.rst +++ b/tools/yaml2rst/templates/ja/faq/article.rst @@ -64,3 +64,4 @@ {% endfor %} {%- endif %} .. translated:: true +