@voodocs/cli 2.2.0 → 2.2.2
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.
- package/lib/darkarts/annotations/parser.py +215 -36
- package/lib/darkarts/documentation/__init__.py +10 -0
- package/lib/darkarts/documentation/categorizer.py +137 -0
- package/lib/darkarts/documentation/consolidator.py +303 -0
- package/lib/darkarts/parsers/typescript/dist/parser.d.ts +16 -0
- package/lib/darkarts/parsers/typescript/dist/parser.d.ts.map +1 -1
- package/lib/darkarts/parsers/typescript/dist/parser.js +64 -0
- package/lib/darkarts/parsers/typescript/dist/parser.js.map +1 -1
- package/lib/darkarts/parsers/typescript/src/parser.ts +68 -0
- package/package.json +2 -1
|
@@ -763,50 +763,229 @@ class AnnotationParser:
|
|
|
763
763
|
language: Language,
|
|
764
764
|
darkarts_matches: List
|
|
765
765
|
) -> ParsedAnnotations:
|
|
766
|
-
"""Parse @darkarts annotations
|
|
767
|
-
from .darkarts_parser import parse_darkarts
|
|
768
|
-
from .translator import DarkArtsTranslator
|
|
766
|
+
"""Parse @darkarts annotations using two-pass approach.
|
|
769
767
|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
768
|
+
Pass 1: Extract code structure using language-specific parser
|
|
769
|
+
Pass 2: Parse annotations and overlay them onto structure by line number
|
|
770
|
+
"""
|
|
771
|
+
from .darkarts_parser import DarkArtsParser
|
|
772
|
+
|
|
773
|
+
# PASS 1: Extract code structure using language-specific parser
|
|
774
|
+
if language == Language.PYTHON:
|
|
775
|
+
# For Python, extract structure using AST
|
|
776
|
+
structure = self._extract_python_structure(source_code, source_file)
|
|
777
|
+
elif language in (Language.TYPESCRIPT, Language.JAVASCRIPT):
|
|
778
|
+
# For TypeScript/JavaScript, use TypeScript parser
|
|
779
|
+
structure = self._extract_typescript_structure(source_file)
|
|
780
|
+
else:
|
|
781
|
+
# For other languages, create empty structure
|
|
782
|
+
structure = self._create_empty_structure(source_file, language)
|
|
783
|
+
|
|
784
|
+
# PASS 2: Parse @darkarts annotations and match to structure
|
|
785
|
+
darkarts_parser = DarkArtsParser()
|
|
786
|
+
annotations_by_line = {}
|
|
773
787
|
|
|
774
788
|
for match in darkarts_matches:
|
|
775
789
|
darkarts_text = match.group(1)
|
|
790
|
+
line_number = source_code[:match.start()].count('\n') + 1
|
|
776
791
|
|
|
777
|
-
# Parse @darkarts annotation
|
|
778
|
-
|
|
779
|
-
parser = DarkArtsParser()
|
|
780
|
-
darkarts_annotation = parser.parse_annotation(darkarts_text)
|
|
781
|
-
|
|
782
|
-
# Process the annotation
|
|
792
|
+
# Parse @darkarts annotation
|
|
793
|
+
darkarts_annotation = darkarts_parser.parse_annotation(darkarts_text)
|
|
783
794
|
if darkarts_annotation:
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
795
|
+
annotations_by_line[line_number] = darkarts_annotation
|
|
796
|
+
|
|
797
|
+
# PASS 3: Overlay annotations onto structure
|
|
798
|
+
return self._overlay_annotations(structure, annotations_by_line)
|
|
799
|
+
|
|
800
|
+
def _extract_python_structure(self, source_code: str, source_file: str) -> ParsedAnnotations:
|
|
801
|
+
"""Extract Python code structure using AST (without annotations)."""
|
|
802
|
+
try:
|
|
803
|
+
tree = ast.parse(source_code)
|
|
804
|
+
except SyntaxError:
|
|
805
|
+
return self._create_empty_structure(source_file, Language.PYTHON)
|
|
806
|
+
|
|
807
|
+
module = ModuleAnnotation(
|
|
808
|
+
name=Path(source_file).stem,
|
|
809
|
+
source_file=source_file,
|
|
810
|
+
language=Language.PYTHON,
|
|
811
|
+
)
|
|
812
|
+
|
|
813
|
+
# Extract functions and classes from AST
|
|
814
|
+
for node in ast.walk(tree):
|
|
815
|
+
if isinstance(node, ast.FunctionDef):
|
|
816
|
+
func = FunctionAnnotation(
|
|
817
|
+
name=node.name,
|
|
818
|
+
line_number=node.lineno,
|
|
819
|
+
)
|
|
820
|
+
module.functions.append(func)
|
|
821
|
+
elif isinstance(node, ast.ClassDef):
|
|
822
|
+
cls = ClassAnnotation(
|
|
823
|
+
name=node.name,
|
|
824
|
+
line_number=node.lineno,
|
|
825
|
+
)
|
|
826
|
+
# Extract methods
|
|
827
|
+
for item in node.body:
|
|
828
|
+
if isinstance(item, ast.FunctionDef):
|
|
829
|
+
method = FunctionAnnotation(
|
|
830
|
+
name=item.name,
|
|
831
|
+
line_number=item.lineno,
|
|
832
|
+
)
|
|
833
|
+
cls.methods.append(method)
|
|
834
|
+
module.classes.append(cls)
|
|
835
|
+
|
|
836
|
+
return ParsedAnnotations(
|
|
837
|
+
module=module,
|
|
838
|
+
language=Language.PYTHON,
|
|
839
|
+
source_file=source_file,
|
|
840
|
+
)
|
|
841
|
+
|
|
842
|
+
def _extract_typescript_structure(self, source_file: str) -> ParsedAnnotations:
|
|
843
|
+
"""Extract TypeScript/JavaScript code structure using TypeScript parser."""
|
|
844
|
+
try:
|
|
845
|
+
check_parser_for_language('typescript')
|
|
846
|
+
except ParserNotBuiltError:
|
|
847
|
+
return self._create_empty_structure(source_file, Language.TYPESCRIPT)
|
|
848
|
+
|
|
849
|
+
# Get the path to the TypeScript parser CLI
|
|
850
|
+
parser_dir = Path(__file__).parent.parent / 'parsers' / 'typescript'
|
|
851
|
+
parser_cli = parser_dir / 'dist' / 'cli.js'
|
|
852
|
+
|
|
853
|
+
if not parser_cli.exists():
|
|
854
|
+
return self._create_empty_structure(source_file, Language.TYPESCRIPT)
|
|
855
|
+
|
|
856
|
+
# Run the TypeScript parser
|
|
857
|
+
try:
|
|
858
|
+
result = subprocess.run(
|
|
859
|
+
['node', str(parser_cli), source_file],
|
|
860
|
+
capture_output=True,
|
|
861
|
+
text=True,
|
|
862
|
+
check=True
|
|
863
|
+
)
|
|
864
|
+
data = json.loads(result.stdout)
|
|
865
|
+
except (subprocess.CalledProcessError, json.JSONDecodeError):
|
|
866
|
+
return self._create_empty_structure(source_file, Language.TYPESCRIPT)
|
|
867
|
+
|
|
868
|
+
# Convert TypeScript parser output to our format
|
|
869
|
+
language = Language.TYPESCRIPT if data['language'] == 'typescript' else Language.JAVASCRIPT
|
|
870
|
+
|
|
871
|
+
module = ModuleAnnotation(
|
|
872
|
+
name=Path(source_file).stem,
|
|
873
|
+
source_file=source_file,
|
|
874
|
+
language=language,
|
|
875
|
+
)
|
|
876
|
+
|
|
877
|
+
# Extract classes
|
|
878
|
+
for cls_data in data.get('classes', []):
|
|
879
|
+
cls = ClassAnnotation(
|
|
880
|
+
name=cls_data['name'],
|
|
881
|
+
line_number=cls_data['line'],
|
|
882
|
+
)
|
|
883
|
+
# Extract methods
|
|
884
|
+
for method_data in cls_data.get('methods', []):
|
|
885
|
+
method = FunctionAnnotation(
|
|
886
|
+
name=method_data['name'],
|
|
887
|
+
line_number=method_data['line'],
|
|
888
|
+
)
|
|
889
|
+
cls.methods.append(method)
|
|
890
|
+
module.classes.append(cls)
|
|
891
|
+
|
|
892
|
+
# Extract functions
|
|
893
|
+
for func_data in data.get('functions', []):
|
|
894
|
+
func = FunctionAnnotation(
|
|
895
|
+
name=func_data['name'],
|
|
896
|
+
line_number=func_data['line'],
|
|
897
|
+
)
|
|
898
|
+
module.functions.append(func)
|
|
899
|
+
|
|
900
|
+
return ParsedAnnotations(
|
|
901
|
+
module=module,
|
|
902
|
+
language=language,
|
|
903
|
+
source_file=source_file,
|
|
904
|
+
)
|
|
905
|
+
|
|
906
|
+
def _create_empty_structure(self, source_file: str, language: Language) -> ParsedAnnotations:
|
|
907
|
+
"""Create empty structure for unsupported languages."""
|
|
908
|
+
module = ModuleAnnotation(
|
|
909
|
+
name=Path(source_file).stem,
|
|
910
|
+
source_file=source_file,
|
|
911
|
+
language=language,
|
|
912
|
+
)
|
|
913
|
+
return ParsedAnnotations(
|
|
914
|
+
module=module,
|
|
915
|
+
language=language,
|
|
916
|
+
source_file=source_file,
|
|
917
|
+
)
|
|
918
|
+
|
|
919
|
+
def _overlay_annotations(self, structure: ParsedAnnotations, annotations_by_line: Dict[int, Any]) -> ParsedAnnotations:
|
|
920
|
+
"""Overlay parsed annotations onto code structure by matching line numbers."""
|
|
921
|
+
# Match annotations to code elements by finding the closest following element
|
|
922
|
+
for line_num, annotation in annotations_by_line.items():
|
|
923
|
+
# Check if this is a module-level annotation (appears before any code)
|
|
924
|
+
if self._is_module_annotation(annotation):
|
|
925
|
+
self._apply_module_annotation_from_darkarts(structure.module, annotation)
|
|
926
|
+
continue
|
|
927
|
+
|
|
928
|
+
# Find the closest function or class after this line
|
|
929
|
+
matched = False
|
|
930
|
+
|
|
931
|
+
# Try to match to a function
|
|
932
|
+
for func in structure.module.functions:
|
|
933
|
+
if func.line_number >= line_num and func.line_number - line_num <= 5:
|
|
934
|
+
self._apply_function_annotation_from_darkarts(func, annotation)
|
|
935
|
+
matched = True
|
|
936
|
+
break
|
|
937
|
+
|
|
938
|
+
if matched:
|
|
939
|
+
continue
|
|
940
|
+
|
|
941
|
+
# Try to match to a class
|
|
942
|
+
for cls in structure.module.classes:
|
|
943
|
+
if cls.line_number >= line_num and cls.line_number - line_num <= 5:
|
|
944
|
+
self._apply_class_annotation_from_darkarts(cls, annotation)
|
|
945
|
+
matched = True
|
|
946
|
+
break
|
|
793
947
|
|
|
794
|
-
#
|
|
795
|
-
|
|
948
|
+
# Try to match to a method within the class
|
|
949
|
+
for method in cls.methods:
|
|
950
|
+
if method.line_number >= line_num and method.line_number - line_num <= 5:
|
|
951
|
+
self._apply_function_annotation_from_darkarts(method, annotation)
|
|
952
|
+
matched = True
|
|
953
|
+
break
|
|
796
954
|
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
955
|
+
if matched:
|
|
956
|
+
break
|
|
957
|
+
|
|
958
|
+
return structure
|
|
959
|
+
|
|
960
|
+
def _is_module_annotation(self, annotation: Any) -> bool:
|
|
961
|
+
"""Check if annotation is module-level."""
|
|
962
|
+
return hasattr(annotation, 'module') and annotation.module
|
|
963
|
+
|
|
964
|
+
def _apply_module_annotation_from_darkarts(self, module: ModuleAnnotation, annotation: Any):
|
|
965
|
+
"""Apply @darkarts annotation to module."""
|
|
966
|
+
if hasattr(annotation, 'module') and annotation.module:
|
|
967
|
+
module.module_purpose = f"Module {{{annotation.module}}}"
|
|
968
|
+
if hasattr(annotation, 'dependencies') and annotation.dependencies:
|
|
969
|
+
module.dependencies = annotation.dependencies
|
|
970
|
+
if hasattr(annotation, 'assumptions') and annotation.assumptions:
|
|
971
|
+
module.assumptions = annotation.assumptions
|
|
972
|
+
|
|
973
|
+
def _apply_function_annotation_from_darkarts(self, func: FunctionAnnotation, annotation: Any):
|
|
974
|
+
"""Apply @darkarts annotation to function."""
|
|
975
|
+
if hasattr(annotation, 'preconditions') and annotation.preconditions:
|
|
976
|
+
func.preconditions = annotation.preconditions
|
|
977
|
+
if hasattr(annotation, 'postconditions') and annotation.postconditions:
|
|
978
|
+
func.postconditions = annotation.postconditions
|
|
979
|
+
if hasattr(annotation, 'invariants') and annotation.invariants:
|
|
980
|
+
func.invariants = annotation.invariants
|
|
981
|
+
if hasattr(annotation, 'performance') and annotation.performance:
|
|
982
|
+
if isinstance(annotation.performance, dict) and 'complexity' in annotation.performance:
|
|
983
|
+
func.complexity = annotation.performance['complexity']
|
|
984
|
+
|
|
985
|
+
def _apply_class_annotation_from_darkarts(self, cls: ClassAnnotation, annotation: Any):
|
|
986
|
+
"""Apply @darkarts annotation to class."""
|
|
987
|
+
if hasattr(annotation, 'invariants') and annotation.invariants:
|
|
988
|
+
cls.invariants = annotation.invariants
|
|
810
989
|
|
|
811
990
|
def _darkarts_to_voodocs_yaml(self, annotation_dict: Dict[str, Any]) -> str:
|
|
812
991
|
"""Convert DarkArts annotation dict to YAML format (legacy)."""
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Documentation Generation Module
|
|
3
|
+
|
|
4
|
+
Provides consolidated, human-readable documentation generation.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .consolidator import DocumentationConsolidator, DocumentedItem
|
|
8
|
+
from .categorizer import AnnotationCategorizer
|
|
9
|
+
|
|
10
|
+
__all__ = ['DocumentationConsolidator', 'DocumentedItem', 'AnnotationCategorizer']
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Annotation Categorizer
|
|
3
|
+
|
|
4
|
+
Extracts categorization metadata from @darkarts annotations.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Dict, Set, Any, List
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class AnnotationCategorizer:
|
|
12
|
+
"""Categorizes code based on @darkarts annotations and file paths."""
|
|
13
|
+
|
|
14
|
+
# Type detection patterns
|
|
15
|
+
TYPE_PATTERNS = {
|
|
16
|
+
'component': ['component', 'tsx', 'jsx', 'ui', 'view'],
|
|
17
|
+
'function': ['function', 'util', 'helper'],
|
|
18
|
+
'module': ['module', 'service', 'manager'],
|
|
19
|
+
'api': ['api', 'route', 'endpoint', 'handler'],
|
|
20
|
+
'data': ['schema', 'model', 'type', 'interface'],
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
# Domain keywords
|
|
24
|
+
DOMAIN_KEYWORDS = {
|
|
25
|
+
'authentication': ['auth', 'login', 'signup', 'session', 'token'],
|
|
26
|
+
'billing': ['billing', 'subscription', 'payment', 'invoice', 'stripe'],
|
|
27
|
+
'admin': ['admin', 'dashboard', 'management'],
|
|
28
|
+
'user_management': ['user', 'account', 'profile'],
|
|
29
|
+
'analytics': ['analytics', 'tracking', 'metrics', 'stats'],
|
|
30
|
+
'marketplace': ['marketplace', 'listing', 'product'],
|
|
31
|
+
'api': ['api', 'endpoint', 'route'],
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# Layer detection
|
|
35
|
+
LAYER_PATTERNS = {
|
|
36
|
+
'frontend': ['component', 'ui', 'view', 'page', 'tsx', 'jsx', 'client'],
|
|
37
|
+
'backend': ['api', 'server', 'route', 'handler', 'controller'],
|
|
38
|
+
'database': ['schema', 'model', 'db', 'database', 'query'],
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@staticmethod
|
|
42
|
+
def detect_type(file_path: str, annotations: Dict[str, Any]) -> str:
|
|
43
|
+
"""Detect the type of code item."""
|
|
44
|
+
path_lower = file_path.lower()
|
|
45
|
+
|
|
46
|
+
# Check file path for type hints
|
|
47
|
+
for item_type, patterns in AnnotationCategorizer.TYPE_PATTERNS.items():
|
|
48
|
+
if any(pattern in path_lower for pattern in patterns):
|
|
49
|
+
return item_type
|
|
50
|
+
|
|
51
|
+
# Check annotations
|
|
52
|
+
if 'module_purpose' in annotations or '⊢' in str(annotations):
|
|
53
|
+
return 'module'
|
|
54
|
+
|
|
55
|
+
return 'other'
|
|
56
|
+
|
|
57
|
+
@staticmethod
|
|
58
|
+
def detect_domains(file_path: str, annotations: Dict[str, Any]) -> Set[str]:
|
|
59
|
+
"""Detect which domains this code belongs to."""
|
|
60
|
+
domains = set()
|
|
61
|
+
path_lower = file_path.lower()
|
|
62
|
+
|
|
63
|
+
# Check file path
|
|
64
|
+
for domain, keywords in AnnotationCategorizer.DOMAIN_KEYWORDS.items():
|
|
65
|
+
if any(keyword in path_lower for keyword in keywords):
|
|
66
|
+
domains.add(domain)
|
|
67
|
+
|
|
68
|
+
# Check annotation content
|
|
69
|
+
annotation_text = str(annotations).lower()
|
|
70
|
+
for domain, keywords in AnnotationCategorizer.DOMAIN_KEYWORDS.items():
|
|
71
|
+
if any(keyword in annotation_text for keyword in keywords):
|
|
72
|
+
domains.add(domain)
|
|
73
|
+
|
|
74
|
+
return domains
|
|
75
|
+
|
|
76
|
+
@staticmethod
|
|
77
|
+
def detect_concerns(annotations: Dict[str, Any]) -> Set[str]:
|
|
78
|
+
"""Detect cross-cutting concerns."""
|
|
79
|
+
concerns = set()
|
|
80
|
+
|
|
81
|
+
# Check for security
|
|
82
|
+
if 'security' in annotations or '🔒' in str(annotations):
|
|
83
|
+
concerns.add('security')
|
|
84
|
+
|
|
85
|
+
# Check for business logic
|
|
86
|
+
if 'business_logic' in annotations:
|
|
87
|
+
concerns.add('business_logic')
|
|
88
|
+
|
|
89
|
+
# Check for performance
|
|
90
|
+
if 'complexity' in annotations or '⚡' in str(annotations):
|
|
91
|
+
concerns.add('performance')
|
|
92
|
+
|
|
93
|
+
# Check for integrations (external dependencies)
|
|
94
|
+
dependencies = annotations.get('dependencies', [])
|
|
95
|
+
if isinstance(dependencies, list):
|
|
96
|
+
external_deps = [d for d in dependencies if not str(d).startswith('.')]
|
|
97
|
+
if external_deps:
|
|
98
|
+
concerns.add('integrations')
|
|
99
|
+
|
|
100
|
+
# Check for error handling
|
|
101
|
+
if 'error_handling' in annotations or 'exceptions' in str(annotations).lower():
|
|
102
|
+
concerns.add('error_handling')
|
|
103
|
+
|
|
104
|
+
return concerns
|
|
105
|
+
|
|
106
|
+
@staticmethod
|
|
107
|
+
def detect_layers(file_path: str, annotations: Dict[str, Any]) -> Set[str]:
|
|
108
|
+
"""Detect which architectural layers this code belongs to."""
|
|
109
|
+
layers = set()
|
|
110
|
+
path_lower = file_path.lower()
|
|
111
|
+
|
|
112
|
+
for layer, patterns in AnnotationCategorizer.LAYER_PATTERNS.items():
|
|
113
|
+
if any(pattern in path_lower for pattern in patterns):
|
|
114
|
+
layers.add(layer)
|
|
115
|
+
|
|
116
|
+
return layers
|
|
117
|
+
|
|
118
|
+
@staticmethod
|
|
119
|
+
def extract_name(file_path: str) -> str:
|
|
120
|
+
"""Extract a human-readable name from file path."""
|
|
121
|
+
path = Path(file_path)
|
|
122
|
+
name = path.stem
|
|
123
|
+
|
|
124
|
+
# Remove common suffixes
|
|
125
|
+
suffixes_to_remove = [
|
|
126
|
+
'.test', '.spec', '.component', '.service',
|
|
127
|
+
'.controller', '.model', '.schema'
|
|
128
|
+
]
|
|
129
|
+
for suffix in suffixes_to_remove:
|
|
130
|
+
if name.endswith(suffix):
|
|
131
|
+
name = name[:-len(suffix)]
|
|
132
|
+
|
|
133
|
+
# Convert kebab-case and snake_case to Title Case
|
|
134
|
+
name = name.replace('-', ' ').replace('_', ' ')
|
|
135
|
+
name = ' '.join(word.capitalize() for word in name.split())
|
|
136
|
+
|
|
137
|
+
return name
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Documentation Consolidator
|
|
3
|
+
|
|
4
|
+
Generates human-readable consolidated documentation from @darkarts annotations.
|
|
5
|
+
Organizes content by multiple categorization schemes for better readability.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import Dict, List, Set, Any
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from dataclasses import dataclass, field
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass
|
|
14
|
+
class DocumentedItem:
|
|
15
|
+
"""Represents a single documented code item."""
|
|
16
|
+
name: str
|
|
17
|
+
file_path: str
|
|
18
|
+
item_type: str # component, function, module, api, etc.
|
|
19
|
+
content: str
|
|
20
|
+
annotations: Dict[str, Any] = field(default_factory=dict)
|
|
21
|
+
|
|
22
|
+
# Categorization metadata
|
|
23
|
+
domains: Set[str] = field(default_factory=set) # auth, billing, admin, etc.
|
|
24
|
+
concerns: Set[str] = field(default_factory=set) # business_logic, security, etc.
|
|
25
|
+
layers: Set[str] = field(default_factory=set) # frontend, backend, database
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class DocumentationConsolidator:
|
|
29
|
+
"""Consolidates scattered documentation into organized, readable documents."""
|
|
30
|
+
|
|
31
|
+
def __init__(self, project_name: str = "Project"):
|
|
32
|
+
self.project_name = project_name
|
|
33
|
+
self.items: List[DocumentedItem] = []
|
|
34
|
+
|
|
35
|
+
def add_item(self, item: DocumentedItem):
|
|
36
|
+
"""Add a documented item to the consolidator."""
|
|
37
|
+
self.items.append(item)
|
|
38
|
+
|
|
39
|
+
def categorize_items(self):
|
|
40
|
+
"""Automatically categorize all items."""
|
|
41
|
+
for item in self.items:
|
|
42
|
+
self._categorize_by_type(item)
|
|
43
|
+
self._categorize_by_path(item)
|
|
44
|
+
self._categorize_by_annotations(item)
|
|
45
|
+
|
|
46
|
+
def _categorize_by_type(self, item: DocumentedItem):
|
|
47
|
+
"""Categorize by code type."""
|
|
48
|
+
# Determine layer from file extension and path
|
|
49
|
+
path_lower = item.file_path.lower()
|
|
50
|
+
|
|
51
|
+
if any(x in path_lower for x in ['component', 'ui', 'view', '.tsx', '.jsx']):
|
|
52
|
+
item.layers.add('frontend')
|
|
53
|
+
if any(x in path_lower for x in ['api', 'server', 'backend', 'route']):
|
|
54
|
+
item.layers.add('backend')
|
|
55
|
+
if any(x in path_lower for x in ['schema', 'model', 'database', 'db']):
|
|
56
|
+
item.layers.add('database')
|
|
57
|
+
|
|
58
|
+
def _categorize_by_path(self, item: DocumentedItem):
|
|
59
|
+
"""Categorize by file path patterns."""
|
|
60
|
+
path_parts = Path(item.file_path).parts
|
|
61
|
+
|
|
62
|
+
# Extract domain from path
|
|
63
|
+
domain_keywords = {
|
|
64
|
+
'auth': 'authentication',
|
|
65
|
+
'billing': 'billing',
|
|
66
|
+
'subscription': 'billing',
|
|
67
|
+
'admin': 'admin',
|
|
68
|
+
'user': 'user_management',
|
|
69
|
+
'account': 'user_management',
|
|
70
|
+
'api': 'api',
|
|
71
|
+
'payment': 'billing',
|
|
72
|
+
'analytics': 'analytics',
|
|
73
|
+
'marketplace': 'marketplace',
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
for part in path_parts:
|
|
77
|
+
part_lower = part.lower()
|
|
78
|
+
for keyword, domain in domain_keywords.items():
|
|
79
|
+
if keyword in part_lower:
|
|
80
|
+
item.domains.add(domain)
|
|
81
|
+
|
|
82
|
+
def _categorize_by_annotations(self, item: DocumentedItem):
|
|
83
|
+
"""Categorize by @darkarts annotation content."""
|
|
84
|
+
annotations = item.annotations
|
|
85
|
+
|
|
86
|
+
# Check for security concerns
|
|
87
|
+
if 'security' in annotations or '🔒' in str(annotations):
|
|
88
|
+
item.concerns.add('security')
|
|
89
|
+
|
|
90
|
+
# Check for business logic
|
|
91
|
+
if 'business_logic' in annotations:
|
|
92
|
+
item.concerns.add('business_logic')
|
|
93
|
+
|
|
94
|
+
# Check for performance
|
|
95
|
+
if 'complexity' in annotations or '⚡' in str(annotations):
|
|
96
|
+
item.concerns.add('performance')
|
|
97
|
+
|
|
98
|
+
# Check for integrations
|
|
99
|
+
dependencies = annotations.get('dependencies', [])
|
|
100
|
+
if any(dep for dep in dependencies if not dep.startswith('.')):
|
|
101
|
+
item.concerns.add('integrations')
|
|
102
|
+
|
|
103
|
+
def generate_by_type(self) -> Dict[str, str]:
|
|
104
|
+
"""Generate documentation organized by type."""
|
|
105
|
+
categories = {
|
|
106
|
+
'component': [],
|
|
107
|
+
'function': [],
|
|
108
|
+
'module': [],
|
|
109
|
+
'api': [],
|
|
110
|
+
'data': [],
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
for item in self.items:
|
|
114
|
+
item_type = item.item_type.lower()
|
|
115
|
+
if item_type in categories:
|
|
116
|
+
categories[item_type].append(item)
|
|
117
|
+
else:
|
|
118
|
+
categories.setdefault('other', []).append(item)
|
|
119
|
+
|
|
120
|
+
docs = {}
|
|
121
|
+
for category, items in categories.items():
|
|
122
|
+
if items:
|
|
123
|
+
docs[f'by-type/{category.upper()}.md'] = self._generate_category_doc(
|
|
124
|
+
f"{category.title()}s",
|
|
125
|
+
items,
|
|
126
|
+
f"All {category}s in the project"
|
|
127
|
+
)
|
|
128
|
+
return docs
|
|
129
|
+
|
|
130
|
+
def generate_by_domain(self) -> Dict[str, str]:
|
|
131
|
+
"""Generate documentation organized by domain."""
|
|
132
|
+
domain_items = {}
|
|
133
|
+
|
|
134
|
+
for item in self.items:
|
|
135
|
+
for domain in item.domains:
|
|
136
|
+
domain_items.setdefault(domain, []).append(item)
|
|
137
|
+
|
|
138
|
+
docs = {}
|
|
139
|
+
for domain, items in domain_items.items():
|
|
140
|
+
docs[f'by-domain/{domain.upper()}.md'] = self._generate_category_doc(
|
|
141
|
+
domain.replace('_', ' ').title(),
|
|
142
|
+
items,
|
|
143
|
+
f"All code related to {domain.replace('_', ' ')}"
|
|
144
|
+
)
|
|
145
|
+
return docs
|
|
146
|
+
|
|
147
|
+
def generate_by_concern(self) -> Dict[str, str]:
|
|
148
|
+
"""Generate documentation organized by concern."""
|
|
149
|
+
concern_items = {}
|
|
150
|
+
|
|
151
|
+
for item in self.items:
|
|
152
|
+
for concern in item.concerns:
|
|
153
|
+
concern_items.setdefault(concern, []).append(item)
|
|
154
|
+
|
|
155
|
+
docs = {}
|
|
156
|
+
for concern, items in concern_items.items():
|
|
157
|
+
docs[f'by-concern/{concern.upper()}.md'] = self._generate_category_doc(
|
|
158
|
+
concern.replace('_', ' ').title(),
|
|
159
|
+
items,
|
|
160
|
+
f"Code with {concern.replace('_', ' ')} considerations"
|
|
161
|
+
)
|
|
162
|
+
return docs
|
|
163
|
+
|
|
164
|
+
def generate_by_layer(self) -> Dict[str, str]:
|
|
165
|
+
"""Generate documentation organized by layer."""
|
|
166
|
+
layer_items = {}
|
|
167
|
+
|
|
168
|
+
for item in self.items:
|
|
169
|
+
for layer in item.layers:
|
|
170
|
+
layer_items.setdefault(layer, []).append(item)
|
|
171
|
+
|
|
172
|
+
docs = {}
|
|
173
|
+
for layer, items in layer_items.items():
|
|
174
|
+
docs[f'by-layer/{layer.upper()}.md'] = self._generate_category_doc(
|
|
175
|
+
f"{layer.title()} Layer",
|
|
176
|
+
items,
|
|
177
|
+
f"All {layer} code"
|
|
178
|
+
)
|
|
179
|
+
return docs
|
|
180
|
+
|
|
181
|
+
def generate_master_readme(self, all_docs: Dict[str, str]) -> str:
|
|
182
|
+
"""Generate master README with overview and navigation."""
|
|
183
|
+
sections = []
|
|
184
|
+
|
|
185
|
+
# Header
|
|
186
|
+
sections.append(f"# {self.project_name} Documentation\n")
|
|
187
|
+
sections.append(f"*Generated by Voodocs from @darkarts annotations*\n")
|
|
188
|
+
sections.append(f"**Total Items Documented:** {len(self.items)}\n")
|
|
189
|
+
sections.append("---\n")
|
|
190
|
+
|
|
191
|
+
# Quick Navigation
|
|
192
|
+
sections.append("## 📚 Documentation Categories\n")
|
|
193
|
+
sections.append("### By Type")
|
|
194
|
+
for doc_path in sorted(all_docs.keys()):
|
|
195
|
+
if doc_path.startswith('by-type/'):
|
|
196
|
+
name = doc_path.replace('by-type/', '').replace('.md', '')
|
|
197
|
+
sections.append(f"- [{name}]({doc_path})")
|
|
198
|
+
sections.append("")
|
|
199
|
+
|
|
200
|
+
sections.append("### By Domain")
|
|
201
|
+
for doc_path in sorted(all_docs.keys()):
|
|
202
|
+
if doc_path.startswith('by-domain/'):
|
|
203
|
+
name = doc_path.replace('by-domain/', '').replace('.md', '')
|
|
204
|
+
sections.append(f"- [{name}]({doc_path})")
|
|
205
|
+
sections.append("")
|
|
206
|
+
|
|
207
|
+
sections.append("### By Concern")
|
|
208
|
+
for doc_path in sorted(all_docs.keys()):
|
|
209
|
+
if doc_path.startswith('by-concern/'):
|
|
210
|
+
name = doc_path.replace('by-concern/', '').replace('.md', '')
|
|
211
|
+
sections.append(f"- [{name}]({doc_path})")
|
|
212
|
+
sections.append("")
|
|
213
|
+
|
|
214
|
+
sections.append("### By Layer")
|
|
215
|
+
for doc_path in sorted(all_docs.keys()):
|
|
216
|
+
if doc_path.startswith('by-layer/'):
|
|
217
|
+
name = doc_path.replace('by-layer/', '').replace('.md', '')
|
|
218
|
+
sections.append(f"- [{name}]({doc_path})")
|
|
219
|
+
sections.append("")
|
|
220
|
+
|
|
221
|
+
sections.append("---\n")
|
|
222
|
+
|
|
223
|
+
# Statistics
|
|
224
|
+
sections.append("## 📊 Project Statistics\n")
|
|
225
|
+
|
|
226
|
+
type_counts = {}
|
|
227
|
+
for item in self.items:
|
|
228
|
+
type_counts[item.item_type] = type_counts.get(item.item_type, 0) + 1
|
|
229
|
+
sections.append("### By Type")
|
|
230
|
+
for item_type, count in sorted(type_counts.items()):
|
|
231
|
+
sections.append(f"- **{item_type.title()}**: {count}")
|
|
232
|
+
sections.append("")
|
|
233
|
+
|
|
234
|
+
# Domain distribution
|
|
235
|
+
domain_counts = {}
|
|
236
|
+
for item in self.items:
|
|
237
|
+
for domain in item.domains:
|
|
238
|
+
domain_counts[domain] = domain_counts.get(domain, 0) + 1
|
|
239
|
+
if domain_counts:
|
|
240
|
+
sections.append("### By Domain")
|
|
241
|
+
for domain, count in sorted(domain_counts.items(), key=lambda x: x[1], reverse=True):
|
|
242
|
+
sections.append(f"- **{domain.replace('_', ' ').title()}**: {count}")
|
|
243
|
+
sections.append("")
|
|
244
|
+
|
|
245
|
+
sections.append("---\n")
|
|
246
|
+
|
|
247
|
+
# Index
|
|
248
|
+
sections.append("## 🔍 Complete Index\n")
|
|
249
|
+
for item in sorted(self.items, key=lambda x: x.name):
|
|
250
|
+
sections.append(f"- **{item.name}** ({item.item_type}) - `{item.file_path}`")
|
|
251
|
+
|
|
252
|
+
return "\n".join(sections)
|
|
253
|
+
|
|
254
|
+
def _generate_category_doc(self, title: str, items: List[DocumentedItem], description: str) -> str:
|
|
255
|
+
"""Generate documentation for a specific category."""
|
|
256
|
+
sections = []
|
|
257
|
+
|
|
258
|
+
sections.append(f"# {title}\n")
|
|
259
|
+
sections.append(f"*{description}*\n")
|
|
260
|
+
sections.append(f"**Items in this category:** {len(items)}\n")
|
|
261
|
+
sections.append("---\n")
|
|
262
|
+
|
|
263
|
+
# Table of contents
|
|
264
|
+
sections.append("## Table of Contents\n")
|
|
265
|
+
for item in sorted(items, key=lambda x: x.name):
|
|
266
|
+
sections.append(f"- [{item.name}](#{item.name.lower().replace(' ', '-')})")
|
|
267
|
+
sections.append("\n---\n")
|
|
268
|
+
|
|
269
|
+
# Items
|
|
270
|
+
for item in sorted(items, key=lambda x: x.name):
|
|
271
|
+
sections.append(f"## {item.name}\n")
|
|
272
|
+
sections.append(f"**Type:** {item.item_type} ")
|
|
273
|
+
sections.append(f"**File:** `{item.file_path}`\n")
|
|
274
|
+
|
|
275
|
+
if item.domains:
|
|
276
|
+
sections.append(f"**Domains:** {', '.join(sorted(item.domains))} ")
|
|
277
|
+
if item.concerns:
|
|
278
|
+
sections.append(f"**Concerns:** {', '.join(sorted(item.concerns))} ")
|
|
279
|
+
if item.layers:
|
|
280
|
+
sections.append(f"**Layers:** {', '.join(sorted(item.layers))} ")
|
|
281
|
+
sections.append("")
|
|
282
|
+
|
|
283
|
+
sections.append(item.content)
|
|
284
|
+
sections.append("\n---\n")
|
|
285
|
+
|
|
286
|
+
return "\n".join(sections)
|
|
287
|
+
|
|
288
|
+
def generate_all(self) -> Dict[str, str]:
|
|
289
|
+
"""Generate all consolidated documentation."""
|
|
290
|
+
# Categorize all items first
|
|
291
|
+
self.categorize_items()
|
|
292
|
+
|
|
293
|
+
# Generate all category docs
|
|
294
|
+
all_docs = {}
|
|
295
|
+
all_docs.update(self.generate_by_type())
|
|
296
|
+
all_docs.update(self.generate_by_domain())
|
|
297
|
+
all_docs.update(self.generate_by_concern())
|
|
298
|
+
all_docs.update(self.generate_by_layer())
|
|
299
|
+
|
|
300
|
+
# Generate master README
|
|
301
|
+
all_docs['README.md'] = self.generate_master_readme(all_docs)
|
|
302
|
+
|
|
303
|
+
return all_docs
|
|
@@ -66,6 +66,22 @@ export declare class TypeScriptAnnotationParser {
|
|
|
66
66
|
* Parse an interface declaration
|
|
67
67
|
*/
|
|
68
68
|
private parseInterface;
|
|
69
|
+
/**
|
|
70
|
+
* Parse a variable statement that may contain function expressions or arrow functions
|
|
71
|
+
*/
|
|
72
|
+
private parseVariableStatement;
|
|
73
|
+
/**
|
|
74
|
+
* Extract parameters from a function expression or arrow function
|
|
75
|
+
*/
|
|
76
|
+
private extractParametersFromExpression;
|
|
77
|
+
/**
|
|
78
|
+
* Extract return type from a function expression or arrow function
|
|
79
|
+
*/
|
|
80
|
+
private extractReturnTypeFromExpression;
|
|
81
|
+
/**
|
|
82
|
+
* Check if a function expression or arrow function is async
|
|
83
|
+
*/
|
|
84
|
+
private isAsyncExpression;
|
|
69
85
|
/**
|
|
70
86
|
* Extract annotations from a node's JSDoc comments
|
|
71
87
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,UAAU,UAAU;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,UAAU,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,UAAU,CAAC;IACxB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,WAAW;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,UAAU,CAAC;IAC/B,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,UAAU,EAAE,aAAa,EAAE,CAAC;CAC7B;AAED,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,UAAU,CAAC;IACxB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,qBAAa,0BAA0B;IAIzB,OAAO,CAAC,QAAQ;IAH5B,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IACI,KAAK,IAAI,WAAW;IAyC3B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAUhC;;OAEG;IACH,OAAO,CAAC,UAAU;IA2BlB;;OAEG;IACH,OAAO,CAAC,aAAa;IAerB;;OAEG;IACH,OAAO,CAAC,WAAW;IAenB;;OAEG;IACH,OAAO,CAAC,cAAc;IAYtB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA6B9B;;OAEG;IACH,OAAO,CAAC,+BAA+B;IAQvC;;OAEG;IACH,OAAO,CAAC,+BAA+B;IAOvC;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAQzB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAe1B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAgB1B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAIzB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA2C3B;;OAEG;IACH,OAAO,CAAC,UAAU;IAmElB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAQzB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAOzB;;OAEG;IACH,OAAO,CAAC,OAAO;IAQf;;OAEG;IACH,OAAO,CAAC,UAAU;IAQlB;;OAEG;IACH,OAAO,CAAC,aAAa;CAItB"}
|
|
@@ -74,6 +74,11 @@ class TypeScriptAnnotationParser {
|
|
|
74
74
|
result.functions.push(funcInfo);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
+
else if (ts.isVariableStatement(node)) {
|
|
78
|
+
// Handle arrow functions and function expressions
|
|
79
|
+
const funcInfos = this.parseVariableStatement(node);
|
|
80
|
+
result.functions.push(...funcInfos);
|
|
81
|
+
}
|
|
77
82
|
else if (ts.isInterfaceDeclaration(node)) {
|
|
78
83
|
const interfaceInfo = this.parseInterface(node);
|
|
79
84
|
if (interfaceInfo) {
|
|
@@ -172,6 +177,65 @@ class TypeScriptAnnotationParser {
|
|
|
172
177
|
is_exported: this.isExported(node)
|
|
173
178
|
};
|
|
174
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Parse a variable statement that may contain function expressions or arrow functions
|
|
182
|
+
*/
|
|
183
|
+
parseVariableStatement(node) {
|
|
184
|
+
const functions = [];
|
|
185
|
+
const isExported = this.isExported(node);
|
|
186
|
+
for (const declaration of node.declarationList.declarations) {
|
|
187
|
+
if (!ts.isVariableDeclaration(declaration))
|
|
188
|
+
continue;
|
|
189
|
+
if (!declaration.initializer)
|
|
190
|
+
continue;
|
|
191
|
+
const name = declaration.name.text;
|
|
192
|
+
if (!name)
|
|
193
|
+
continue;
|
|
194
|
+
// Check if the initializer is a function expression or arrow function
|
|
195
|
+
const init = declaration.initializer;
|
|
196
|
+
if (ts.isFunctionExpression(init) || ts.isArrowFunction(init)) {
|
|
197
|
+
functions.push({
|
|
198
|
+
name,
|
|
199
|
+
line: this.getLineNumber(declaration),
|
|
200
|
+
parameters: this.extractParametersFromExpression(init),
|
|
201
|
+
return_type: this.extractReturnTypeFromExpression(init),
|
|
202
|
+
annotations: this.extractAnnotations(node),
|
|
203
|
+
is_async: this.isAsyncExpression(init),
|
|
204
|
+
is_exported: isExported
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return functions;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Extract parameters from a function expression or arrow function
|
|
212
|
+
*/
|
|
213
|
+
extractParametersFromExpression(node) {
|
|
214
|
+
return node.parameters.map(param => {
|
|
215
|
+
const name = param.name.text;
|
|
216
|
+
const type = param.type ? `: ${param.type.getText(this.sourceFile)}` : '';
|
|
217
|
+
return `${name}${type}`;
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Extract return type from a function expression or arrow function
|
|
222
|
+
*/
|
|
223
|
+
extractReturnTypeFromExpression(node) {
|
|
224
|
+
if (node.type) {
|
|
225
|
+
return node.type.getText(this.sourceFile);
|
|
226
|
+
}
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Check if a function expression or arrow function is async
|
|
231
|
+
*/
|
|
232
|
+
isAsyncExpression(node) {
|
|
233
|
+
if (ts.canHaveModifiers(node)) {
|
|
234
|
+
const modifiers = ts.getModifiers(node);
|
|
235
|
+
return modifiers?.some((m) => m.kind === ts.SyntaxKind.AsyncKeyword) || false;
|
|
236
|
+
}
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
175
239
|
/**
|
|
176
240
|
* Extract annotations from a node's JSDoc comments
|
|
177
241
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+CAAiC;AACjC,uCAAyB;AAyCzB,MAAa,0BAA0B;IAIrC,YAAoB,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;QAClC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACrD,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC,gBAAgB,CACnC,QAAQ,EACR,IAAI,CAAC,UAAU,EACf,EAAE,CAAC,YAAY,CAAC,MAAM,EACtB,IAAI,CACL,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,KAAK;QACV,MAAM,MAAM,GAAgB;YAC1B,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY;YACrE,kBAAkB,EAAE,IAAI,CAAC,wBAAwB,EAAE;YACnD,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,EAAE;YACb,UAAU,EAAE,EAAE;SACf,CAAC;QAEF,6BAA6B;QAC7B,MAAM,KAAK,GAAG,CAAC,IAAa,EAAE,EAAE;YAC9B,IAAI,EAAE,CAAC,kB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ED;;OAEG;IACK,OAAO,CAAC,IAAmD;QACjE,IAAI,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,SAAS,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACxC,OAAO,SAAS,EAAE,IAAI,CAAC,CAAC,CAAc,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC;QAC7F,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACK,UAAU,CAAC,IAAa;QAC9B,IAAI,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,SAAS,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACxC,OAAO,SAAS,EAAE,IAAI,CAAC,CAAC,CAAc,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC;QAC9F,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,IAAa;QACjC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,6BAA6B,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAChF,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,uBAAuB;IAC1C,CAAC;CACF;AA1aD,gEA0aC"}
|
|
@@ -86,6 +86,10 @@ export class TypeScriptAnnotationParser {
|
|
|
86
86
|
if (funcInfo) {
|
|
87
87
|
result.functions.push(funcInfo);
|
|
88
88
|
}
|
|
89
|
+
} else if (ts.isVariableStatement(node)) {
|
|
90
|
+
// Handle arrow functions and function expressions
|
|
91
|
+
const funcInfos = this.parseVariableStatement(node);
|
|
92
|
+
result.functions.push(...funcInfos);
|
|
89
93
|
} else if (ts.isInterfaceDeclaration(node)) {
|
|
90
94
|
const interfaceInfo = this.parseInterface(node);
|
|
91
95
|
if (interfaceInfo) {
|
|
@@ -195,6 +199,70 @@ export class TypeScriptAnnotationParser {
|
|
|
195
199
|
};
|
|
196
200
|
}
|
|
197
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Parse a variable statement that may contain function expressions or arrow functions
|
|
204
|
+
*/
|
|
205
|
+
private parseVariableStatement(node: ts.VariableStatement): FunctionInfo[] {
|
|
206
|
+
const functions: FunctionInfo[] = [];
|
|
207
|
+
const isExported = this.isExported(node);
|
|
208
|
+
|
|
209
|
+
for (const declaration of node.declarationList.declarations) {
|
|
210
|
+
if (!ts.isVariableDeclaration(declaration)) continue;
|
|
211
|
+
if (!declaration.initializer) continue;
|
|
212
|
+
|
|
213
|
+
const name = (declaration.name as ts.Identifier).text;
|
|
214
|
+
if (!name) continue;
|
|
215
|
+
|
|
216
|
+
// Check if the initializer is a function expression or arrow function
|
|
217
|
+
const init = declaration.initializer;
|
|
218
|
+
if (ts.isFunctionExpression(init) || ts.isArrowFunction(init)) {
|
|
219
|
+
functions.push({
|
|
220
|
+
name,
|
|
221
|
+
line: this.getLineNumber(declaration),
|
|
222
|
+
parameters: this.extractParametersFromExpression(init),
|
|
223
|
+
return_type: this.extractReturnTypeFromExpression(init),
|
|
224
|
+
annotations: this.extractAnnotations(node),
|
|
225
|
+
is_async: this.isAsyncExpression(init),
|
|
226
|
+
is_exported: isExported
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return functions;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Extract parameters from a function expression or arrow function
|
|
236
|
+
*/
|
|
237
|
+
private extractParametersFromExpression(node: ts.FunctionExpression | ts.ArrowFunction): string[] {
|
|
238
|
+
return node.parameters.map(param => {
|
|
239
|
+
const name = (param.name as ts.Identifier).text;
|
|
240
|
+
const type = param.type ? `: ${param.type.getText(this.sourceFile)}` : '';
|
|
241
|
+
return `${name}${type}`;
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Extract return type from a function expression or arrow function
|
|
247
|
+
*/
|
|
248
|
+
private extractReturnTypeFromExpression(node: ts.FunctionExpression | ts.ArrowFunction): string | null {
|
|
249
|
+
if (node.type) {
|
|
250
|
+
return node.type.getText(this.sourceFile);
|
|
251
|
+
}
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Check if a function expression or arrow function is async
|
|
257
|
+
*/
|
|
258
|
+
private isAsyncExpression(node: ts.FunctionExpression | ts.ArrowFunction): boolean {
|
|
259
|
+
if (ts.canHaveModifiers(node)) {
|
|
260
|
+
const modifiers = ts.getModifiers(node);
|
|
261
|
+
return modifiers?.some((m: ts.Modifier) => m.kind === ts.SyntaxKind.AsyncKeyword) || false;
|
|
262
|
+
}
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
|
|
198
266
|
/**
|
|
199
267
|
* Extract annotations from a node's JSDoc comments
|
|
200
268
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voodocs/cli",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "AI-Native Symbolic Documentation System - The world's first documentation tool using mathematical notation with semantic validation",
|
|
5
5
|
"main": "voodocs_cli.py",
|
|
6
6
|
"bin": {
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"lib/darkarts/core/",
|
|
61
61
|
"lib/darkarts/validation/",
|
|
62
62
|
"lib/darkarts/instructions/",
|
|
63
|
+
"lib/darkarts/documentation/",
|
|
63
64
|
"lib/darkarts/exceptions.py",
|
|
64
65
|
"lib/darkarts/telemetry.py",
|
|
65
66
|
"lib/darkarts/parsers/typescript/dist/",
|