Skip to content

Commit 6f623f8

Browse files
authored
Merge pull request #289 from ma10/refactor-yaml2x-20250308
yaml2xのリファクタリング
2 parents 456bf81 + 2a54233 commit 6f623f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+185
-81
lines changed

build.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
rootdir = $(ROOTDIR)
2-
PYTHON?= python
3-
YAML2RST= $(PYTHON) $(rootdir)/tools/yaml2x/yaml2rst/yaml2rst.py -b $(rootdir) -l $(lang)
2+
#PYTHON?= python
3+
YAML2RST= yaml2rst -b $(rootdir) -l $(lang)
44

55
ifneq ($(BASE_URL),)
66
html_baseurl = $(BASE_URL)

requirements.txt

+2-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@ wheel
22
sphinx >= 3.0
33
sphinx_rtd_theme
44
sphinxcontrib-trimblank
5-
pyyaml
6-
toml
75
jsonschema < 4.18.0
8-
GitPython
96
sphinx-lint
10-
google-auth-oauthlib
11-
google-api-python-client
127
pytz
13-
pydantic
14-
tools/yaml2x/libs/freee_a11y_gl
8+
tools/lib/freee_a11y_gl
9+
tools/scripts/yaml2rst

tools/yaml2x/libs/freee_a11y_gl/pyproject.toml tools/lib/freee_a11y_gl/pyproject.toml

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ authors = [
1010
{name = "Masafumi NAKANE", email = "[email protected]"}
1111
]
1212
requires-python = ">=3.8"
13+
dependencies = [
14+
"pyyaml>=6.0",
15+
"gitpython>=3.1.43",
16+
"pydantic>=2.7.0"
17+
]
1318

1419
[tool.setuptools]
15-
packages = { find = {} }
20+
package-dir = { "" = "src" }

tools/yaml2x/libs/freee_a11y_gl/freee_a11y_gl/config.yaml.sample tools/lib/freee_a11y_gl/src/freee_a11y_gl/config.yaml.sample

+26-18
Original file line numberDiff line numberDiff line change
@@ -41,34 +41,42 @@ locale:
4141
pass_plural_text: " are true" # Pass condition text for multiple conditions
4242
date_format: "%B %-d, %Y" # Date format in strftime format
4343

44-
# Validation settings
45-
# Check severity levels and their display names
44+
# Severity tags configuration
4645
severity_tags:
4746
ja:
48-
must: "必須"
49-
should: "推奨"
47+
minor: "[MINOR]"
48+
normal: "[NORMAL]"
49+
major: "[MAJOR]"
50+
critical: "[CRITICAL]"
5051
en:
51-
must: "Must"
52-
should: "Should"
52+
minor: "[MINOR]"
53+
normal: "[NORMAL]"
54+
major: "[MAJOR]"
55+
critical: "[CRITICAL]"
5356

54-
# Check target types and their display names
57+
# Check targets configuration
5558
check_targets:
5659
ja:
57-
code: "コード" # For code-level checks
58-
content: "コンテンツ" # For content-level checks
60+
design: "デザイン"
61+
code: "コード"
62+
product: "プロダクト"
5963
en:
60-
code: "Code" # For code-level checks
61-
content: "Content" # For content-level checks
64+
design: "Design"
65+
code: "Code"
66+
product: "Product"
6267

6368
# Platform settings
6469
platform:
65-
# Platform display names used for both platform indication and implementation targets
6670
names:
6771
ja:
68-
web: "Webアプリケーション" # Web application specific
69-
mobile: "モバイルアプリケーション" # Mobile application specific
70-
general: "全般" # Platform independent
72+
web: "Web"
73+
mobile: "モバイル"
74+
general: "全般"
75+
ios: "iOS"
76+
android: "Android"
7177
en:
72-
web: "Web Application" # Web application specific
73-
mobile: "Mobile Application" # Mobile application specific
74-
general: "General" # Platform independent
78+
web: "Web"
79+
mobile: "Mobile"
80+
general: "General"
81+
ios: "iOS"
82+
android: "Android"

tools/yaml2x/libs/freee_a11y_gl/freee_a11y_gl/settings.py tools/lib/freee_a11y_gl/src/freee_a11y_gl/settings.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88

99
class LocaleConfig(BaseModel):
1010
"""Locale-specific configuration."""
11-
text_separator: str = Field(default=": ", description="Text separator for the category and the title for guideline links")
12-
list_separator: str = Field(default=", ", description="List item separator")
13-
and_separator: str = Field(default=" and ", description="AND conjunction")
14-
or_separator: str = Field(default=" or ", description="OR conjunction")
15-
and_conjunction: str = Field(default=", and ", description="AND conjunction for grouped items")
16-
or_conjunction: str = Field(default=", or ", description="OR conjunction for grouped items")
17-
pass_singular_text: str = Field(default=" is true", description="Pass condition text for single condition")
18-
pass_plural_text: str = Field(default=" are true", description="Pass condition text for multiple conditions")
19-
date_format: str = Field(default="%B %-d, %Y", description="Date format in strftime format")
11+
text_separator: str = Field(description="Text separator for the category and the title for guideline links")
12+
list_separator: str = Field(description="List item separator")
13+
and_separator: str = Field(description="AND conjunction")
14+
or_separator: str = Field(description="OR conjunction")
15+
and_conjunction: str = Field(description="AND conjunction for grouped items")
16+
or_conjunction: str = Field(description="OR conjunction for grouped items")
17+
pass_singular_text: str = Field(description="Pass condition text for single condition")
18+
pass_plural_text: str = Field(description="Pass condition text for multiple conditions")
19+
date_format: str = Field(description="Date format in strftime format")
2020

2121
class LanguageConfig(BaseModel):
2222
"""Language configuration."""

tools/scripts/yaml2rst/MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
graft src/yaml2rst/templates

tools/scripts/yaml2rst/pyproject.toml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "yaml2rst"
7+
version = "0.1.0"
8+
description = "Process YAML files into reStructuredText to e included in the guidelines document."
9+
readme = "README.md"
10+
authors = [
11+
{ name = "Masafumi NAKANE", email = "[email protected]" }
12+
]
13+
dependencies = [
14+
"jinja2",
15+
"freee_a11y_gl>=0.1.0",
16+
]
17+
requires-python = ">=3.8"
18+
19+
[tool.setuptools]
20+
package-dir = {"" = "src"}
21+
include-package-data = true
22+
23+
[tool.setuptools.packages.find]
24+
where = ["src"]
25+
include = ["yaml2rst*"]
26+
27+
[project.scripts]
28+
yaml2rst = "yaml2rst.yaml2rst:main"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = '0.1.0'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""Main entry point for yaml2rst when run with python -m yaml2rst."""
2+
from .yaml2rst import main
3+
4+
if __name__ == '__main__':
5+
main()
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""Package for RST file generation components."""
2+
from .base_generator import BaseGenerator, GeneratorError, ValidationError
3+
from .file_generator import FileGenerator, GeneratorConfig
4+
from .common_generators import ListBasedGenerator, SingleFileGenerator
5+
from .content_generators import (
6+
CategoryGenerator,
7+
AllChecksGenerator, CheckExampleGenerator,
8+
FaqArticleGenerator, FaqTagPageGenerator, FaqIndexGenerator,
9+
FaqTagIndexGenerator, FaqArticleIndexGenerator,
10+
WcagMappingGenerator, PriorityDiffGenerator, MiscDefinitionsGenerator,
11+
InfoToGuidelinesGenerator, InfoToFaqsGenerator,
12+
AxeRulesGenerator,
13+
MakefileGenerator,
14+
MakefileConfig
15+
)
16+
17+
__all__ = [
18+
'BaseGenerator',
19+
'GeneratorError',
20+
'ValidationError',
21+
'FileGenerator',
22+
'GeneratorConfig',
23+
'ListBasedGenerator',
24+
'SingleFileGenerator',
25+
'CategoryGenerator',
26+
'AllChecksGenerator, CheckExampleGenerator',
27+
'FaqArticleGenerator, FaqTagPageGenerator, FaqIndexGenerator',
28+
'FaqTagIndexGenerator, FaqArticleIndexGenerator',
29+
'WcagMappingGenerator, PriorityDiffGenerator, MiscDefinitionsGenerator',
30+
'InfoToGuidelinesGenerator, InfoToFaqsGenerator',
31+
'AxeRulesGenerator',
32+
'MakefileGenerator',
33+
'MakefileConfig'
34+
]

tools/yaml2x/yaml2rst/generators/file_generator.py tools/scripts/yaml2rst/src/yaml2rst/generators/file_generator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from pathlib import Path
66
import logging
77

8-
from template_manager import TemplateManager
8+
from ..template_manager import TemplateManager
99
from .base_generator import BaseGenerator, GeneratorError
1010

1111
@dataclass(frozen=True)

tools/yaml2x/yaml2rst/initializer.py tools/scripts/yaml2rst/src/yaml2rst/initializer.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import os
22
import argparse
3-
import config
4-
from path import get_dest_dirnames, get_static_dest_files, TEMPLATE_DIR, TEMPLATE_FILENAMES
3+
from . import config
4+
from .path import get_dest_dirnames, get_static_dest_files, TEMPLATE_DIR, TEMPLATE_FILENAMES
55
from freee_a11y_gl.source import get_src_path
6-
from template_manager import TemplateManager
6+
from .template_manager import TemplateManager
77

88
def setup_parameters():
99
args = parse_args()

tools/yaml2x/yaml2rst/path.py tools/scripts/yaml2rst/src/yaml2rst/path.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
from config import AVAILABLE_LANGUAGES
2+
from .config import AVAILABLE_LANGUAGES
33
from freee_a11y_gl.source import DATA_DIR, YAML_DIR, JSON_DIR
44
from freee_a11y_gl.constants import AXE_CORE
55

tools/yaml2x/yaml2rst/yaml2rst.py tools/scripts/yaml2rst/src/yaml2rst/yaml2rst.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import os
55
from pathlib import Path
66

7-
import initializer
8-
from generators.file_generator import FileGenerator, GeneratorConfig
9-
from generators.content_generators import (
7+
from . import initializer
8+
from .generators.file_generator import FileGenerator, GeneratorConfig
9+
from .generators.content_generators import (
1010
CategoryGenerator,
1111
AllChecksGenerator, CheckExampleGenerator,
1212
FaqArticleGenerator, FaqTagPageGenerator, FaqIndexGenerator,
File renamed without changes.

tools/scripts/yaml2sheet/MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include src/yaml2sheet/*.sample
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "yaml2sheet"
7+
version = "0.1.0"
8+
description = "Generate checklist in Google Sheets from YAML data"
9+
readme = "README.md"
10+
authors = [
11+
{ name = "Masafumi NAKANE", email = "[email protected]" }
12+
]
13+
dependencies = [
14+
"google-api-python-client",
15+
"google-auth-oauthlib",
16+
"sphinx",
17+
"toml",
18+
"freee_a11y_gl>=0.1.0"
19+
]
20+
requires-python = ">=3.8"
21+
22+
[tool.setuptools]
23+
package-dir = {"" = "src"}
24+
include-package-data = true
25+
26+
[tool.setuptools.packages.find]
27+
where = ["src"]
28+
include = ["yaml2sheet*"]
29+
30+
[project.scripts]
31+
yaml2sheet = "yaml2sheet.yaml2sheet:main"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""Generate checklist in Google Sheets from YAML data."""
2+
3+
from .yaml2sheet import main
4+
from .config_loader import ApplicationConfig
5+
from .auth import GoogleAuthManager
6+
from .sheet_generator import ChecklistSheetGenerator
7+
8+
__version__ = "0.1.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""Command line entry point for yaml2sheet."""
2+
from .yaml2sheet import main
3+
4+
if __name__ == '__main__':
5+
main()

tools/yaml2x/yaml2sheet/condition_formatter.py tools/scripts/yaml2sheet/src/yaml2sheet/condition_formatter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import Dict, List
2-
from config import M17nField, Condition, COLUMNS
2+
from .config import M17nField, Condition, COLUMNS
33

44
class ConditionFormatter:
55
"""Handles creation and formatting of conditional formulas for sheet cells"""

tools/yaml2x/yaml2sheet/data_processor.py tools/scripts/yaml2sheet/src/yaml2sheet/data_processor.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Dict, List, Any
22
import logging
3-
from config import TARGET_NAMES, M17nField
4-
from sheet_structure import CheckInfo
3+
from .config import TARGET_NAMES, M17nField, COLUMNS
4+
from .sheet_structure import CheckInfo
55

66
logger = logging.getLogger(__name__)
77

@@ -70,7 +70,6 @@ def _has_generated_data(self, sheet_names: List[str]) -> bool:
7070
Returns:
7171
bool: True if any sheets require generated data
7272
"""
73-
from config import COLUMNS
7473
return any(
7574
bool(COLUMNS[name]['generatedData'])
7675
for name in sheet_names

tools/yaml2x/yaml2sheet/sheet_formatter.py tools/scripts/yaml2sheet/src/yaml2sheet/sheet_formatter.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Dict, List, Optional
22
import logging
3-
from sheet_structure import SheetStructure
4-
from config import CHECK_RESULTS, FINAL_CHECK_RESULTS
3+
from .sheet_structure import SheetStructure
4+
from .config import CHECK_RESULTS, FINAL_CHECK_RESULTS, COLUMNS
55

66
logger = logging.getLogger(__name__)
77

@@ -128,7 +128,6 @@ def get_result_column_index(self) -> int:
128128
Returns:
129129
int: Index of result column
130130
"""
131-
from config import COLUMNS
132131
return len(COLUMNS['idCols']) + len(COLUMNS[self.current_target]['generatedData'])
133132

134133
def add_protection_settings(self, sheet_id: int, sheet: SheetStructure) -> List[Dict]:
@@ -141,8 +140,6 @@ def add_protection_settings(self, sheet_id: int, sheet: SheetStructure) -> List[
141140
Returns:
142141
List[Dict]: List of protection requests
143142
"""
144-
from config import COLUMNS
145-
146143
requests = []
147144
data_length = len(sheet.data)
148145

tools/yaml2x/yaml2sheet/sheet_generator.py tools/scripts/yaml2sheet/src/yaml2sheet/sheet_generator.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
from google.oauth2.credentials import Credentials
55
from googleapiclient.discovery import build
66

7-
from config import TARGET_NAMES, LANGS, COLUMN_INFO, CHECK_RESULTS, FINAL_CHECK_RESULTS, COLUMNS
8-
from sheet_structure import SheetStructure, CheckInfo
9-
from cell_data import CellData, CellType
10-
from condition_formatter import ConditionFormatter
11-
from sheet_formatter import SheetFormatter
12-
from data_processor import DataProcessor
13-
from utils import create_version_info_request, adjust_sheet_size
7+
from .config import TARGET_NAMES, LANGS, COLUMN_INFO, CHECK_RESULTS, FINAL_CHECK_RESULTS, COLUMNS
8+
from .sheet_structure import SheetStructure, CheckInfo
9+
from .cell_data import CellData, CellType
10+
from .condition_formatter import ConditionFormatter
11+
from .sheet_formatter import SheetFormatter
12+
from .data_processor import DataProcessor
13+
from .utils import create_version_info_request, adjust_sheet_size
1414

1515
logger = logging.getLogger(__name__)
1616

@@ -423,7 +423,7 @@ def _add_plain_data_columns(
423423
lang: Language code
424424
row_data: Row data to append to
425425
"""
426-
from utils import l10n_string
426+
from .utils import l10n_string
427427

428428
plain_headers = [
429429
*COLUMNS['common']['plainData1'],

tools/yaml2x/yaml2sheet/sheet_structure.py tools/scripts/yaml2sheet/src/yaml2sheet/sheet_structure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import List, Dict, Optional
22
from dataclasses import dataclass, field
3-
from cell_data import CellData
3+
from .cell_data import CellData
44

55
@dataclass
66
class ColumnProperties:

tools/yaml2x/yaml2sheet/utils.py tools/scripts/yaml2sheet/src/yaml2sheet/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import Dict, List, Any, Union
2-
from config import M17nField
2+
from .config import M17nField
33

44
def format_statement_summary(statement: M17nField) -> M17nField:
55
"""Format a check statement summary into a complete sentence

tools/yaml2x/yaml2sheet/yaml2sheet.py tools/scripts/yaml2sheet/src/yaml2sheet/yaml2sheet.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import argparse
55
from typing import Optional
66
from pathlib import Path
7-
from auth import GoogleAuthManager
8-
from sheet_generator import ChecklistSheetGenerator
9-
from config_loader import load_configuration, ApplicationConfig
7+
from .auth import GoogleAuthManager
8+
from .sheet_generator import ChecklistSheetGenerator
9+
from .config_loader import load_configuration, ApplicationConfig
1010
from googleapiclient.errors import HttpError
1111
from google.oauth2.credentials import Credentials
1212

0 commit comments

Comments
 (0)