diff options
| author | 2025-03-15 14:15:13 +0800 | |
|---|---|---|
| committer | 2025-03-15 14:15:13 +0800 | |
| commit | eb00c504f1fae5f0301adf25011e98cbb78cc79d (patch) | |
| tree | c6971c11999467e4009e99e8fb5ec7c85e47c529 | |
| parent | ee15a8b3174048f1c9f7f53a51d1e5b7a2410054 (diff) | |
| parent | eeef7f3ed7209c5f6b8e101d132a91e372a7dd6d (diff) | |
| download | conventional_role_play-eb00c504f1fae5f0301adf25011e98cbb78cc79d.tar.gz conventional_role_play-eb00c504f1fae5f0301adf25011e98cbb78cc79d.zip | |
Merge branch 'main' into main
| -rw-r--r-- | .github/workflows/CI.yml | 43 | ||||
| -rw-r--r-- | CHANGELOG.md | 21 | ||||
| -rw-r--r-- | Cargo.toml | 14 | ||||
| -rw-r--r-- | README.md | 80 | ||||
| -rw-r--r-- | README.rst | 4 | ||||
| -rw-r--r-- | examples/basic_usage.py | 8 | ||||
| -rw-r--r-- | examples/custom_plugin.py | 2 | ||||
| -rw-r--r-- | pyproject.toml | 4 | ||||
| -rw-r--r-- | src/conventionalrp/__init__.py | 17 | ||||
| -rw-r--r-- | src/conventionalrp/_core.pyi | 2 | ||||
| -rw-r--r-- | src/conventionalrp/core/__init__.py | 4 | ||||
| -rw-r--r-- | src/conventionalrp/extractors/__init__.py | 2 | ||||
| -rw-r--r-- | src/conventionalrp/plugins/__init__.py | 2 | ||||
| -rw-r--r-- | src/conventionalrp/renderers/__init__.py | 2 | ||||
| -rw-r--r-- | src/conventionalrp/utils/__init__.py | 2 | ||||
| -rw-r--r-- | uv.lock | 2 |
16 files changed, 179 insertions, 30 deletions
diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 34d6b29..177ee90 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -38,6 +38,9 @@ jobs: target: ppc64le steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.9 - name: Build wheels uses: PyO3/maturin-action@v1 with: @@ -45,6 +48,13 @@ jobs: args: --release --out dist sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} manylinux: auto + - name: Build free-threaded wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist + sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} + manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v4 with: @@ -66,6 +76,9 @@ jobs: target: armv7 steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.9 - name: Build wheels uses: PyO3/maturin-action@v1 with: @@ -73,6 +86,13 @@ jobs: args: --release --out dist sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} manylinux: musllinux_1_2 + - name: Build free-threaded wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist + sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} + manylinux: musllinux_1_2 - name: Upload wheels uses: actions/upload-artifact@v4 with: @@ -90,12 +110,22 @@ jobs: target: x86 steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.9 + architecture: ${{ matrix.platform.target }} - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} args: --release --out dist sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} + - name: Build free-threaded wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist + sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} - name: Upload wheels uses: actions/upload-artifact@v4 with: @@ -113,12 +143,21 @@ jobs: target: aarch64 steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.9 - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} args: --release --out dist sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} + - name: Build free-threaded wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist + sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} - name: Upload wheels uses: actions/upload-artifact@v4 with: @@ -162,7 +201,7 @@ jobs: if: ${{ startsWith(github.ref, 'refs/tags/') }} uses: PyO3/maturin-action@v1 env: - MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} with: command: upload - args: --non-interactive --skip-existing wheels-*/* + args: --non-interactive --skip-existing wheels-*/*
\ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..317bed2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,21 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v0.2.2] - 2025-03-14 +### Chores +- [`6d3a6d8`](https://github.com/HydroRoll-Team/conventional_role_play/commit/6d3a6d851d88e572e2125932febfb9844064a7d1) - replace README.rst with README.md and update pyproject.toml to reference new README format *(commit by [@HsiangNianian](https://github.com/HsiangNianian))* +- [`1ddf2a5`](https://github.com/HydroRoll-Team/conventional_role_play/commit/1ddf2a5202e065a5df18dfa58a88faa5784a3f8c) - bump version to 0.2.2 and update version retrieval method in __init__.py *(commit by [@HsiangNianian](https://github.com/HsiangNianian))* + + +## [v0.2.1] - 2025-03-14 +### Chores +- [`00e130b`](https://github.com/HydroRoll-Team/conventional_role_play/commit/00e130b06051a7d250d2a0a9b901d46cbd9eb756) - update CI workflow to use Python 3.9 and add interpreter finding option *(commit by [@HsiangNianian](https://github.com/HsiangNianian))* +- [`fb5b1fb`](https://github.com/HydroRoll-Team/conventional_role_play/commit/fb5b1fbba51d68619d64f53e68164cc7a7741370) - update CI workflow to consistently use Python 3.9 and remove unnecessary interpreter arguments *(commit by [@HsiangNianian](https://github.com/HsiangNianian))* +- [`a10578c`](https://github.com/HydroRoll-Team/conventional_role_play/commit/a10578cfd63151739b36f9cc5ba81a4c0eda05ec) - bump version to 0.2.1 in Cargo.toml and __init__.py *(commit by [@HsiangNianian](https://github.com/HsiangNianian))* +- [`9b696f0`](https://github.com/HydroRoll-Team/conventional_role_play/commit/9b696f003a2b7da575ea086c6ddc0c579a13f46b) - rename project to conventionalrp and update metadata in Cargo.toml and pyproject.toml *(commit by [@HsiangNianian](https://github.com/HsiangNianian))* + +[v0.2.1]: https://github.com/HydroRoll-Team/conventional_role_play/compare/v0.2.0...v0.2.1 +[v0.2.2]: https://github.com/HydroRoll-Team/conventional_role_play/compare/v0.2.1...v0.2.2 @@ -1,13 +1,13 @@ [package] -name = "pyo3_template" -version = "0.0.1" +name = "conventionalrp" +version = "0.2.2" edition = "2021" -description = "A Pyo3 Project Template For HydroRoll." -license = "MIT" +description = "HydroRoll Conventional Role Play SDK" +license = "AGPLv3.0" documentation = "https://{project}.hydroroll.team/" -homepage = "https://hydroroll.team/" -repository = "https://github.com/HydroRoll-Team/{project}" -authors = ["yourname"] +homepage = "https://crp.hydroroll.team/" +repository = "https://github.com/HydroRoll-Team/conventional_role_play" +authors = ["HsiangNianian"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] diff --git a/README.md b/README.md new file mode 100644 index 0000000..dba71ff --- /dev/null +++ b/README.md @@ -0,0 +1,80 @@ +# Conventional Role Play + +## 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 contributing for more information. + +## Key Features + +* **Rule Extraction**: Easily extract rules from JSON configuration files using the `RuleExtractor` class. +* **Multi-format Rendering**: Render outputs in various formats such as HTML, Markdown, and JSON using the respective renderer classes (e.g., `HTMLRenderer`). +* **Extensibility**: Create custom plugins to extend the functionality of the SDK. See custom-plugins for details. +* **Comprehensive API**: Full API documentation available for all modules and classes. See api-documentation. + +## Installation + +To install Conventional Role Play, you can use pip: + +```bash +pip install conventionalrp +``` + +## Basic Usage + +Here is a simple example of how to use the TRPG Log Processor: + +```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 + +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](https://crp.hydroroll.team/api.html). + +## License + +This project is licensed under the AGPLv3.0 License - see the + +LICENSE + + file for details. + +## Project Links + +* [Homepage](https://hydroroll.team/) +* [Documentation](https://crp.hydroroll.team/) +* [GitHub Repository](https://github.com/HydroRoll-Team/conventional_role_play)
\ No newline at end of file diff --git a/README.rst b/README.rst deleted file mode 100644 index 3db479d..0000000 --- a/README.rst +++ /dev/null @@ -1,4 +0,0 @@ -pyo3-project-template -===================== - -HydroRoll Pyo3 Project Template diff --git a/examples/basic_usage.py b/examples/basic_usage.py index e2209da..22bfbe4 100644 --- a/examples/basic_usage.py +++ b/examples/basic_usage.py @@ -1,7 +1,7 @@ -from trpg_log_processor.core.parser import Parser -from trpg_log_processor.core.processor import Processor -from trpg_log_processor.extractors.rule_extractor import RuleExtractor -from trpg_log_processor.renderers.html_renderer import HTMLRenderer +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 def main(): # Initialize the parser and load rules diff --git a/examples/custom_plugin.py b/examples/custom_plugin.py index 74a0bcc..5ae6581 100644 --- a/examples/custom_plugin.py +++ b/examples/custom_plugin.py @@ -1,4 +1,4 @@ -from trpg_log_processor.plugins.plugin_manager import PluginManager +from conventionalrp.plugins.plugin_manager import PluginManager class CustomPlugin: def __init__(self): diff --git a/pyproject.toml b/pyproject.toml index e8f26b1..37f1421 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,9 +9,7 @@ description = "HydroRoll Conventional Role Play SDK" authors = [{ name = "HsiangNianian", email = "leader@hydroroll.team" }] dependencies = [] requires-python = ">=3.9" -readme.content-type = "text/x-rst" -readme.text = """ -""" +readme = "README.md" license = { text = "AGPLv3.0" } keywords = ["hydroroll"] classifiers = [ diff --git a/src/conventionalrp/__init__.py b/src/conventionalrp/__init__.py index 4522950..bad6a58 100644 --- a/src/conventionalrp/__init__.py +++ b/src/conventionalrp/__init__.py @@ -1 +1,16 @@ -from . import _core
\ No newline at end of file +from . import _core + +__all__ = ["_core", "__version__"] + +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") 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 @@ -172,7 +172,7 @@ wheels = [ ] [[package]] -name = "conventional-role-play" +name = "conventionalrp" source = { editable = "." } [package.dev-dependencies] |
