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 --- .github/workflows/CI.yml | 41 ++++++++++++++++++++++++++++++- examples/basic_usage.py | 8 +++--- examples/custom_plugin.py | 2 +- 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 +- uv.lock | 2 +- 10 files changed, 53 insertions(+), 14 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 34d6b29..ca2f0ec 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.x - 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 -i python3.13t + 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.x - 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 -i python3.13t + 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.x + 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 -i python3.13t + 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.x - 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 -i python3.13t + 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-*/* 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/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 diff --git a/uv.lock b/uv.lock index 96f94f7..72093e4 100644 --- a/uv.lock +++ b/uv.lock @@ -172,7 +172,7 @@ wheels = [ ] [[package]] -name = "conventional-role-play" +name = "conventionalrp" source = { editable = "." } [package.dev-dependencies] -- 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(-) 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 7368f06242c8cabc8a813d60e99957ad854865e0 Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Fri, 14 Mar 2025 01:04:37 +0800 Subject: chore: bump version to 0.2.0 in Cargo.toml --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index b263dfb..c82fe05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyo3_template" -version = "0.1.0" +version = "0.2.0" edition = "2021" description = "A Pyo3 Project Template For HydroRoll." license = "MIT" -- 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(-) 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 00e130b06051a7d250d2a0a9b901d46cbd9eb756 Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Fri, 14 Mar 2025 21:59:27 +0800 Subject: chore: update CI workflow to use Python 3.9 and add interpreter finding option --- .github/workflows/CI.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ca2f0ec..5fafbab 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -40,12 +40,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.x + python-version: '3.9' - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} - args: --release --out dist + args: --release --out dist --find-interpreter sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} manylinux: auto - name: Build free-threaded wheels -- cgit v1.2.3-70-g09d2 From fb5b1fbba51d68619d64f53e68164cc7a7741370 Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Fri, 14 Mar 2025 22:04:59 +0800 Subject: chore: update CI workflow to consistently use Python 3.9 and remove unnecessary interpreter arguments --- .github/workflows/CI.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5fafbab..177ee90 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -40,19 +40,19 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: 3.9 - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} - args: --release --out dist --find-interpreter + 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 -i python3.13t + args: --release --out dist sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} manylinux: auto - name: Upload wheels @@ -78,7 +78,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.x + python-version: 3.9 - name: Build wheels uses: PyO3/maturin-action@v1 with: @@ -90,7 +90,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} - args: --release --out dist -i python3.13t + args: --release --out dist sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} manylinux: musllinux_1_2 - name: Upload wheels @@ -112,7 +112,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.x + python-version: 3.9 architecture: ${{ matrix.platform.target }} - name: Build wheels uses: PyO3/maturin-action@v1 @@ -124,7 +124,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} - args: --release --out dist -i python3.13t + args: --release --out dist sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} - name: Upload wheels uses: actions/upload-artifact@v4 @@ -145,7 +145,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.x + python-version: 3.9 - name: Build wheels uses: PyO3/maturin-action@v1 with: @@ -156,7 +156,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} - args: --release --out dist -i python3.13t + args: --release --out dist sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} - name: Upload wheels uses: actions/upload-artifact@v4 @@ -204,4 +204,4 @@ jobs: 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 -- 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(-) 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 9b696f003a2b7da575ea086c6ddc0c579a13f46b Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Fri, 14 Mar 2025 22:12:53 +0800 Subject: chore: rename project to conventionalrp and update metadata in Cargo.toml and pyproject.toml --- Cargo.toml | 12 ++++++------ pyproject.toml | 3 +-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c44b23c..982bd5d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,13 +1,13 @@ [package] -name = "pyo3_template" +name = "conventionalrp" version = "0.2.1" 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/pyproject.toml b/pyproject.toml index e8f26b1..71d6eaf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,8 +10,7 @@ authors = [{ name = "HsiangNianian", email = "leader@hydroroll.team" }] dependencies = [] requires-python = ">=3.9" readme.content-type = "text/x-rst" -readme.text = """ -""" +readme.file = "README.rst" license = { text = "AGPLv3.0" } keywords = ["hydroroll"] classifiers = [ -- cgit v1.2.3-70-g09d2 From c0dc250f29f88ab995fccbde16798a0c9c43f987 Mon Sep 17 00:00:00 2001 From: HsiangNianian <44714368+HsiangNianian@users.noreply.github.com> Date: Fri, 14 Mar 2025 14:13:56 +0000 Subject: docs: update CHANGELOG.md for v0.2.1 [skip ci] --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..758c201 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +# 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.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 -- cgit v1.2.3-70-g09d2 From 6d3a6d851d88e572e2125932febfb9844064a7d1 Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Fri, 14 Mar 2025 22:43:01 +0800 Subject: chore: replace README.rst with README.md and update pyproject.toml to reference new README format --- README.md | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++ README.rst | 91 ---------------------------------------------------------- pyproject.toml | 3 +- 3 files changed, 81 insertions(+), 93 deletions(-) create mode 100644 README.md delete mode 100644 README.rst 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 fe57e5a..0000000 --- a/README.rst +++ /dev/null @@ -1,91 +0,0 @@ -Conventional Role Play -====================== - -.. 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/pyproject.toml b/pyproject.toml index 71d6eaf..37f1421 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,8 +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.file = "README.rst" +readme = "README.md" license = { text = "AGPLv3.0" } keywords = ["hydroroll"] classifiers = [ -- 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(-) 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 From eeef7f3ed7209c5f6b8e101d132a91e372a7dd6d Mon Sep 17 00:00:00 2001 From: HsiangNianian <44714368+HsiangNianian@users.noreply.github.com> Date: Fri, 14 Mar 2025 14:51:57 +0000 Subject: docs: update CHANGELOG.md for v0.2.2 [skip ci] --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 758c201..317bed2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ 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))* @@ -12,3 +18,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [`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 -- cgit v1.2.3-70-g09d2