blob: d1c381bd244a6a767e0535e4ee4024fbb988c5f2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# API Documentation for TRPG Log Processor
## Overview
The TRPG Log Processor SDK provides a structured way to parse, extract, and render logs from tabletop role-playing games (TRPGs). This document outlines the key components of the SDK, including classes, methods, and their functionalities.
## Core Components
### Parser
- **Class**: `Parser`
- **Module**: `src/conventionalrp/core/parser.py`
- **Methods**:
- `parse_log(log: str) -> List[Token]`: Parses a TRPG log string and returns a list of tokens.
- `load_rules(rules_file: str) -> None`: Loads parsing rules from a specified file.
### Processor
- **Class**: `Processor`
- **Module**: `src/conventionalrp/core/processor.py`
- **Methods**:
- `process_tokens(tokens: List[Token]) -> None`: Processes a list of tokens.
- `generate_output(format: str) -> str`: Generates output in the specified format (e.g., HTML, Markdown, JSON).
## Extractors
### BaseExtractor
- **Class**: `BaseExtractor`
- **Module**: `src/conventionalrp/extractors/base.py`
- **Methods**:
- `extract(data: Any) -> Any`: Extracts relevant data based on defined rules.
- `load_rules(rules_file: str) -> None`: Loads extraction rules from a specified file.
### RuleExtractor
- **Class**: `RuleExtractor`
- **Module**: `src/conventionalrp/extractors/rule_extractor.py`
- **Methods**:
- `extract(data: Any) -> List[Rule]`: Extracts rules from JSON configuration files.
## Renderers
### BaseRenderer
- **Class**: `BaseRenderer`
- **Module**: `src/conventionalrp/renderers/base.py`
- **Methods**:
- `render(data: Any) -> str`: Renders data into a specific format.
- `set_style(style: str) -> None`: Sets the rendering style.
### HTMLRenderer
- **Class**: `HTMLRenderer`
- **Module**: `src/conventionalrp/renderers/html_renderer.py`
- **Methods**:
- `render(data: Any) -> str`: Renders data into HTML format.
### MarkdownRenderer
- **Class**: `MarkdownRenderer`
- **Module**: `src/conventionalrp/renderers/markdown_renderer.py`
- **Methods**:
- `render(data: Any) -> str`: Renders data into Markdown format.
### JSONRenderer
- **Class**: `JSONRenderer`
- **Module**: `src/conventionalrp/renderers/json_renderer.py`
- **Methods**:
- `render(data: Any) -> str`: Renders data into JSON format.
## Plugins
### PluginManager
- **Class**: `PluginManager`
- **Module**: `src/conventionalrp/plugins/plugin_manager.py`
- **Methods**:
- `load_plugins() -> None`: Loads available plugins.
- `execute_plugin(name: str, data: Any) -> Any`: Executes a specified plugin with the provided data.
## Utilities
### Text Processing
- **Module**: `src/conventionalrp/utils/text_processing.py`
- **Functions**:
- `tokenize(text: str) -> List[str]`: Tokenizes input text into a list of tokens.
- `match_regex(pattern: str, text: str) -> List[str]`: Matches a regex pattern against the input text.
## Conclusion
This API documentation provides a comprehensive overview of the TRPG Log Processor SDK. For detailed usage instructions and examples, please refer to the `usage.md` file in the `docs` directory.
|