Verified with の順番が不定
beet-aizu opened this issue · comments
beet commented
Kimiyuki Onaka commented
(1.)「依存関係を解析して Python の構造体にまとめる」(2.)「Python の構造体から JSON を生成する」(3.)「Markdown に埋め込まれた JSON あるいは YAML から HTML を生成する」という過程で最終的な出力が得られています。このどこかにソート処理を入れてください。どこを修正しても動くけど (2.) の部分である次を修正するのがよさそう?
verification-helper/onlinejudge_verify/documentation/build.py
Lines 65 to 114 in 3c92524
def _render_source_code_stat(stat: SourceCodeStat, *, basedir: pathlib.Path) -> Dict[str, Any]: | |
with open(basedir / stat.path, 'rb') as fh: | |
code = fh.read().decode() | |
try: | |
language = onlinejudge_verify.languages.list.get(stat.path) | |
assert language is not None | |
bundled_code = language.bundle(stat.path, basedir=basedir).decode() | |
except Exception: | |
logger.warning("failed to bundle: %s", str(stat.path)) | |
bundled_code = traceback.format_exc() | |
return { | |
'path': str(stat.path), | |
'code': code, | |
'bundledCode': bundled_code, | |
'isVerificationFile': stat.is_verification_file, | |
'verificationStatus': stat.verification_status.value, | |
'timestamp': str(stat.timestamp), | |
'dependsOn': [str(path) for path in stat.depends_on], | |
'requiredBy': [str(path) for path in stat.required_by], | |
'verifiedWith': [str(path) for path in stat.verified_with], | |
'attributes': stat.attributes, | |
} | |
def _render_source_code_stat_for_page( | |
path: pathlib.Path, | |
*, | |
source_code_stats_dict: Dict[pathlib.Path, SourceCodeStat], | |
page_title_dict: Dict[pathlib.Path, str], | |
basedir: pathlib.Path, | |
) -> Dict[str, Any]: | |
relative_path = (basedir / path).resolve().relative_to(basedir) | |
stat = source_code_stats_dict[relative_path] | |
data = _render_source_code_stat(stat, basedir=basedir) | |
data['_pathExtension'] = path.suffix.lstrip('.') | |
data['_verificationStatusIcon'] = _get_verification_status_icon(stat.verification_status) | |
def ext(relative_path: pathlib.Path) -> Dict[str, Any]: | |
stat = source_code_stats_dict[relative_path] | |
return { | |
'path': str(relative_path), | |
'title': page_title_dict[relative_path], | |
'icon': _get_verification_status_icon(stat.verification_status), | |
} | |
data['_extendedDependsOn'] = [ext(path) for path in stat.depends_on] | |
data['_extendedRequiredBy'] = [ext(path) for path in stat.required_by] | |
data['_extendedVerifiedWith'] = [ext(path) for path in stat.verified_with] | |
return data |