From 83980eb447150c765d37fcd8124596e1972e14a1 Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Fri, 14 Mar 2025 00:54:59 +0800 Subject: refactor: update project structure and rename modules to conventionalrp --- src/conventionalrp/_core.pyi | 2 +- src/conventionalrp/core/__init__.py | 4 ++-- src/conventionalrp/extractors/__init__.py | 2 +- src/conventionalrp/plugins/__init__.py | 2 +- src/conventionalrp/renderers/__init__.py | 2 +- src/conventionalrp/utils/__init__.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/conventionalrp/_core.pyi b/src/conventionalrp/_core.pyi index 4945a82..8a0cc40 100644 --- a/src/conventionalrp/_core.pyi +++ b/src/conventionalrp/_core.pyi @@ -1,3 +1,3 @@ -def sum_as_string(self, a: int, b: int) -> str: ... +def sum_as_string(a: int, b: int) -> str: ... class Base: ... \ No newline at end of file diff --git a/src/conventionalrp/core/__init__.py b/src/conventionalrp/core/__init__.py index 7097e41..d63b2a9 100644 --- a/src/conventionalrp/core/__init__.py +++ b/src/conventionalrp/core/__init__.py @@ -1,4 +1,4 @@ -# FILE: /trpg-log-processor/trpg-log-processor/src/trpg_log_processor/core/__init__.py +# FILE: /trpg-log-processor/trpg-log-processor/src/conventionalrp/core/__init__.py """ -This file initializes the core module of the trpg_log_processor SDK. +This file initializes the core module of the conventionalrp SDK. """ \ No newline at end of file diff --git a/src/conventionalrp/extractors/__init__.py b/src/conventionalrp/extractors/__init__.py index d27a5eb..c076f07 100644 --- a/src/conventionalrp/extractors/__init__.py +++ b/src/conventionalrp/extractors/__init__.py @@ -1,4 +1,4 @@ -# FILE: /trpg-log-processor/trpg-log-processor/src/trpg_log_processor/extractors/__init__.py +# FILE: /trpg-log-processor/trpg-log-processor/src/conventionalrp/extractors/__init__.py """ This file initializes the extractors module. """ \ No newline at end of file diff --git a/src/conventionalrp/plugins/__init__.py b/src/conventionalrp/plugins/__init__.py index 32fa8a0..9f1a11b 100644 --- a/src/conventionalrp/plugins/__init__.py +++ b/src/conventionalrp/plugins/__init__.py @@ -1,4 +1,4 @@ -# FILE: /trpg-log-processor/trpg-log-processor/src/trpg_log_processor/plugins/__init__.py +# FILE: /trpg-log-processor/trpg-log-processor/src/conventionalrp/plugins/__init__.py """ This file initializes the plugins module. """ \ No newline at end of file diff --git a/src/conventionalrp/renderers/__init__.py b/src/conventionalrp/renderers/__init__.py index ce04364..7838674 100644 --- a/src/conventionalrp/renderers/__init__.py +++ b/src/conventionalrp/renderers/__init__.py @@ -1,4 +1,4 @@ -# FILE: /trpg-log-processor/trpg-log-processor/src/trpg_log_processor/renderers/__init__.py +# FILE: /trpg-log-processor/trpg-log-processor/src/conventionalrp/renderers/__init__.py """ This file initializes the renderers module. """ \ No newline at end of file diff --git a/src/conventionalrp/utils/__init__.py b/src/conventionalrp/utils/__init__.py index 20153b2..44b1840 100644 --- a/src/conventionalrp/utils/__init__.py +++ b/src/conventionalrp/utils/__init__.py @@ -1,2 +1,2 @@ -# FILE: /trpg-log-processor/trpg-log-processor/src/trpg_log_processor/utils/__init__.py +# FILE: /trpg-log-processor/trpg-log-processor/src/conventionalrp/utils/__init__.py """This file initializes the utils module.""" \ No newline at end of file -- cgit v1.2.3-70-g09d2 From de2917678b0ef6d3c5c16bb1e2ef973aa3d3adba Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Fri, 14 Mar 2025 01:04:07 +0800 Subject: chore: update version to 0.1.0 and enhance README with project overview and usage examples --- Cargo.toml | 2 +- README.rst | 93 ++++++++++++++++++++++++++++++++++++++++-- src/conventionalrp/__init__.py | 6 ++- 3 files changed, 96 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/Cargo.toml b/Cargo.toml index 58a78cc..b263dfb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyo3_template" -version = "0.0.1" +version = "0.1.0" edition = "2021" description = "A Pyo3 Project Template For HydroRoll." license = "MIT" diff --git a/README.rst b/README.rst index 3db479d..fe57e5a 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,91 @@ -pyo3-project-template -===================== +Conventional Role Play +====================== -HydroRoll Pyo3 Project Template +.. image:: https://cdn.jsdelivr.net/gh/HydroRoll-Team/HydroRoll@main/docs/_static/logo.png + :alt: HydroRoll Logo + :width: 200px + :align: center + +Overview +-------- + +Conventional Role Play (CRP) is a Python SDK designed for structured processing of tabletop role-playing game (TRPG) logs. It provides functionalities for parsing logs, extracting rules, and rendering outputs in multiple formats. This SDK aims to streamline the analysis and presentation of TRPG session data. + +.. note:: + This documentation is still under construction. Contributions are welcome! See :ref:`contributing` for more information. + +Key Features +------------ + +* **Rule Extraction**: Easily extract rules from JSON configuration files using the :class:`RuleExtractor `. +* **Multi-format Rendering**: Render outputs in various formats such as HTML, Markdown, and JSON using the respective renderer classes (e.g., :class:`HTMLRenderer `). +* **Extensibility**: Create custom plugins to extend the functionality of the SDK. See :ref:`custom-plugins` for details. +* **Comprehensive API**: Full API documentation available for all modules and classes. See :ref:`api-documentation`. + +Installation +------------ + +To install Conventional Role Play, you can use pip: + +.. code-block:: bash + + pip install conventionalrp + +Basic Usage +----------- + +Here is a simple example of how to use the TRPG Log Processor: + +.. code-block:: python + + from conventionalrp.core.parser import Parser + from conventionalrp.core.processor import Processor + from conventionalrp.extractors.rule_extractor import RuleExtractor + from conventionalrp.renderers.html_renderer import HTMLRenderer + + # Step 1: Load rules + rule_extractor = RuleExtractor() + rules = rule_extractor.load_rules('path/to/rules.json') + + # Step 2: Parse the log + parser = Parser(rules) + parsed_log = parser.parse_log('path/to/log.txt') + + # Step 3: Process the parsed tokens + processor = Processor() + output = processor.process_tokens(parsed_log) + + # Step 4: Render the output + renderer = HTMLRenderer() + html_output = renderer.render(output) + + # Save or display the output + with open('output.html', 'w') as f: + f.write(html_output) + +Custom Plugins +-------------- + +To create a custom plugin, you can follow the example provided in :file:`examples/custom_plugin.py`. This allows you to add additional processing or rendering capabilities tailored to your needs. + +API Documentation +----------------- + +For more detailed information on the API and available classes, please refer to the `API documentation `_. + +License +------- + +This project is licensed under the AGPLv3.0 License - see the `LICENSE `_ file for details. + +Project Links +------------- + +* `Homepage `_ +* `Documentation `_ +* `GitHub Repository `_ + +.. _contributing: contributing.html +.. _api-documentation: api.html +.. _LICENSE: LICENSE +.. _custom-plugins: examples/custom_plugin.py \ No newline at end of file diff --git a/src/conventionalrp/__init__.py b/src/conventionalrp/__init__.py index 4522950..139e58b 100644 --- a/src/conventionalrp/__init__.py +++ b/src/conventionalrp/__init__.py @@ -1 +1,5 @@ -from . import _core \ No newline at end of file +from . import _core + +from packaging.version import Version + +__version__ = Version('0.1.0') -- cgit v1.2.3-70-g09d2 From 05c1e4a9380a96bf04b5c8c49d06c2859b9f21c6 Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Fri, 14 Mar 2025 01:04:54 +0800 Subject: chore: update version to 0.2.0 in __init__.py --- src/conventionalrp/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/conventionalrp/__init__.py b/src/conventionalrp/__init__.py index 139e58b..9707310 100644 --- a/src/conventionalrp/__init__.py +++ b/src/conventionalrp/__init__.py @@ -2,4 +2,4 @@ from . import _core from packaging.version import Version -__version__ = Version('0.1.0') +__version__ = Version('0.2.0') -- cgit v1.2.3-70-g09d2 From a10578cfd63151739b36f9cc5ba81a4c0eda05ec Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Fri, 14 Mar 2025 22:11:18 +0800 Subject: chore: bump version to 0.2.1 in Cargo.toml and __init__.py --- Cargo.toml | 2 +- src/conventionalrp/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/Cargo.toml b/Cargo.toml index c82fe05..c44b23c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyo3_template" -version = "0.2.0" +version = "0.2.1" edition = "2021" description = "A Pyo3 Project Template For HydroRoll." license = "MIT" diff --git a/src/conventionalrp/__init__.py b/src/conventionalrp/__init__.py index 9707310..83ed8ce 100644 --- a/src/conventionalrp/__init__.py +++ b/src/conventionalrp/__init__.py @@ -2,4 +2,4 @@ from . import _core from packaging.version import Version -__version__ = Version('0.2.0') +__version__ = Version('0.2.1') -- cgit v1.2.3-70-g09d2 From 1ddf2a5202e065a5df18dfa58a88faa5784a3f8c Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Fri, 14 Mar 2025 22:51:17 +0800 Subject: chore: bump version to 0.2.2 and update version retrieval method in __init__.py --- Cargo.toml | 2 +- src/conventionalrp/__init__.py | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/Cargo.toml b/Cargo.toml index 982bd5d..efd1fb8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "conventionalrp" -version = "0.2.1" +version = "0.2.2" edition = "2021" description = "HydroRoll Conventional Role Play SDK" license = "AGPLv3.0" diff --git a/src/conventionalrp/__init__.py b/src/conventionalrp/__init__.py index 83ed8ce..bad6a58 100644 --- a/src/conventionalrp/__init__.py +++ b/src/conventionalrp/__init__.py @@ -1,5 +1,16 @@ from . import _core -from packaging.version import Version +__all__ = ["_core", "__version__"] -__version__ = Version('0.2.1') +from importlib.metadata import version +from pkg_resources import get_distribution + +try: + # For Python 3.8+ + __version__ = version("conventionalrp") +except ImportError: + try: + # For Python < 3.8 + __version__ = get_distribution("conventionalrp").version + except Exception: + raise ImportError("Failed to get version") -- cgit v1.2.3-70-g09d2