@skspwork/config-doc 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  import { FileSystemService } from './fileSystem';
2
2
  import { StorageService } from './storage';
3
3
  import { escapeTableCell, getPropertyByPath, formatValue } from './utils';
4
+ import { ConfigParser } from './configParser';
4
5
 
5
6
  export class MarkdownTableGenerator {
6
7
  private rootPath: string;
@@ -33,52 +34,58 @@ export class MarkdownTableGenerator {
33
34
  markdown += `## ${fileName}\n\n`;
34
35
  markdown += `**ファイルパス:** \`${filePath}\`\n\n`;
35
36
 
36
- const propertyEntries = Object.entries(docs.properties);
37
- if (propertyEntries.length === 0) {
38
- markdown += '*ドキュメントが登録されていません。*\n\n';
37
+ // 設定ファイルから全プロパティを取得(オブジェクト型も含む)
38
+ // ツリー構造の順序を保持するためソートしない
39
+ const allPropertyPaths = ConfigParser.getAllPropertyPaths(configData);
40
+
41
+ if (allPropertyPaths.length === 0) {
42
+ markdown += '*プロパティがありません。*\n\n';
39
43
  continue;
40
44
  }
41
45
 
42
46
  // すべてのフィールドラベルを収集(説明以外)
43
47
  const fieldLabels = new Set<string>();
44
- propertyEntries.forEach(([_, doc]) => {
45
- Object.keys(doc.fields).forEach(label => {
46
- if (label !== '説明') {
47
- fieldLabels.add(label);
48
- }
49
- });
48
+ allPropertyPaths.forEach(propertyPath => {
49
+ const doc = docs.properties[propertyPath];
50
+ if (doc && doc.fields) {
51
+ Object.keys(doc.fields).forEach(label => {
52
+ if (label !== '説明') {
53
+ fieldLabels.add(label);
54
+ }
55
+ });
56
+ }
50
57
  });
51
58
  const sortedLabels = Array.from(fieldLabels).sort();
52
59
 
53
60
  // テーブルヘッダー
54
- markdown += '| プロパティ名 | タグ | 説明 | 値 |';
61
+ markdown += '| プロパティ名 | タグ | 値 |';
55
62
  sortedLabels.forEach(label => {
56
63
  markdown += ` ${label} |`;
57
64
  });
58
65
  markdown += '\n';
59
66
 
60
- markdown += '|-------------|------|------|-----|';
67
+ markdown += '|-------------|------|-----|';
61
68
  sortedLabels.forEach(() => {
62
69
  markdown += '------|';
63
70
  });
64
71
  markdown += '\n';
65
72
 
66
73
  // 各プロパティの行を追加
67
- for (const [propertyPath, doc] of propertyEntries) {
74
+ for (const propertyPath of allPropertyPaths) {
75
+ const doc = docs.properties[propertyPath];
68
76
  const propertyName = escapeTableCell(propertyPath);
69
- const tags = doc.tags && doc.tags.length > 0
77
+ const tags = doc && doc.tags && doc.tags.length > 0
70
78
  ? escapeTableCell(doc.tags.map(tag => `\`${tag}\``).join(', '))
71
79
  : '-';
72
80
 
73
- const description = escapeTableCell(doc.fields['説明'] || '-');
74
81
  const value = this.getPropertyValue(configData, propertyPath);
75
82
  const valueStr = escapeTableCell(value);
76
83
 
77
- markdown += `| ${propertyName} | ${tags} | ${description} | ${valueStr} |`;
84
+ markdown += `| ${propertyName} | ${tags} | ${valueStr} |`;
78
85
 
79
86
  // フィールドの値を追加(説明以外)
80
87
  sortedLabels.forEach(label => {
81
- const fieldValue = doc.fields[label] || '-';
88
+ const fieldValue = (doc && doc.fields && doc.fields[label]) || '-';
82
89
  markdown += ` ${escapeTableCell(fieldValue)} |`;
83
90
  });
84
91
 
@@ -88,7 +95,7 @@ export class MarkdownTableGenerator {
88
95
  markdown += '\n';
89
96
  }
90
97
 
91
- markdown += `\n*このドキュメントは [ConfigDoc](https://github.com/your-repo/configdoc) により自動生成されました。*\n`;
98
+ markdown += `\n*このドキュメントは ConfigDoc により自動生成されました。*\n`;
92
99
 
93
100
  return markdown;
94
101
  }