Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit13d9d7d

Browse files
EdwardAngertclaude
andcommitted
chore: add analyze_docs.py script for docs analysis
- Add external Python script for document structure analysis- Improves maintainability by separating Python code from YAML- Handles document heading counts and title extraction- Includes error handling for corrupted files🤖 Generated with [Claude Code](https://claude.ai/code)Co-Authored-By: Claude <noreply@anthropic.com>
1 parent69515e6 commit13d9d7d

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env python3
2+
importsys
3+
importjson
4+
importos
5+
importre
6+
7+
files_to_analyze=sys.stdin.read().strip().split('\n')
8+
doc_structure= {}
9+
10+
forfile_pathinfiles_to_analyze:
11+
ifnotfile_pathornotfile_path.endswith('.md')ornotos.path.isfile(file_path):
12+
continue
13+
14+
try:
15+
withopen(file_path,'r',encoding='utf-8')asf:
16+
content=f.read()
17+
18+
# Extract title (first h1)
19+
title_match=re.search(r'^# (.+)$',content,re.MULTILINE)
20+
title=title_match.group(1)iftitle_matchelse'Untitled'
21+
22+
# Count headings
23+
h1_count=len(re.findall(r'^# ',content,re.MULTILINE))
24+
h2_count=len(re.findall(r'^## ',content,re.MULTILINE))
25+
h3_count=len(re.findall(r'^### ',content,re.MULTILINE))
26+
27+
doc_structure[file_path]= {
28+
'title':title,
29+
'headings': {
30+
'h1':h1_count,
31+
'h2':h2_count,
32+
'h3':h3_count
33+
}
34+
}
35+
36+
print(f'Analyzed{file_path}: H1={h1_count}, H2={h2_count}, H3={h3_count}, Title="{title}"',file=sys.stderr)
37+
exceptExceptionase:
38+
print(f'Error analyzing{file_path}:{str(e)}',file=sys.stderr)
39+
40+
# Write JSON output
41+
withopen('.github/temp/doc_structure.json','w',encoding='utf-8')asf:
42+
json.dump(doc_structure,f,indent=2)
43+
44+
print(json.dumps(doc_structure))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp