diff --git a/docs/source/index.md b/docs/source/index.md new file mode 100644 index 0000000..8e7c1c9 --- /dev/null +++ b/docs/source/index.md @@ -0,0 +1,15 @@ +# libWiiPy API Docs + +```{toctree} +:maxdepth: 2 +:caption: Contents: +``` + +Welcome to the API documentation website for libWiiPy! libWiiPy is a modern Python 3 library for handling the various files and formats found on the Wii. + + +## Indices and tables + +* [Full Index]() +* [Module Index]() +* diff --git a/docs/source/index.rst b/docs/source/index.rst deleted file mode 100644 index 859042d..0000000 --- a/docs/source/index.rst +++ /dev/null @@ -1,20 +0,0 @@ -.. libWiiPy documentation master file, created by - sphinx-quickstart on Tue Jun 25 17:09:58 2024. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -Welcome to libWiiPy's documentation! -==================================== - -.. toctree:: - :maxdepth: 2 - :caption: Contents: - - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/docs/source/libWiiPy.archive.rst b/docs/source/libWiiPy.archive.md similarity index 55% rename from docs/source/libWiiPy.archive.rst rename to docs/source/libWiiPy.archive.md index ce1a4b3..f5b1830 100644 --- a/docs/source/libWiiPy.archive.rst +++ b/docs/source/libWiiPy.archive.md @@ -1,29 +1,28 @@ -libWiiPy.archive package -======================== +# libWiiPy.archive package -Submodules ----------- +## Submodules -libWiiPy.archive.ash module ---------------------------- +### libWiiPy.archive.ash module +```{eval-rst} .. automodule:: libWiiPy.archive.ash :members: :undoc-members: :show-inheritance: +``` +### libWiiPy.archive.u8 module -libWiiPy.archive.u8 module --------------------------- - +```{eval-rst} .. automodule:: libWiiPy.archive.u8 :members: :undoc-members: :show-inheritance: +``` +## Module contents -Module contents ---------------- - +```{eval-rst} .. automodule:: libWiiPy.archive :members: :undoc-members: :show-inheritance: +``` diff --git a/docs/source/libWiiPy.md b/docs/source/libWiiPy.md new file mode 100644 index 0000000..873e05c --- /dev/null +++ b/docs/source/libWiiPy.md @@ -0,0 +1,34 @@ +# libWiiPy package + +## Subpackages + +```{toctree} +:maxdepth: 4 + +libWiiPy.archive +libWiiPy.title +``` + +## Submodules + +### libWiiPy.shared module + +libWiiPy's ``shared`` module is private and contains only private functions used by other modules. + +```{eval-rst} +.. automodule:: libWiiPy.shared + :members: + :undoc-members: + :show-inheritance: +``` + +### libWiiPy.types module + +libWiiPy's ``types`` module is private and contains only private classes used by other modules. + +```{eval-rst} +.. automodule:: libWiiPy.types + :members: + :undoc-members: + :show-inheritance: +``` diff --git a/docs/source/libWiiPy.rst b/docs/source/libWiiPy.rst deleted file mode 100644 index c11384a..0000000 --- a/docs/source/libWiiPy.rst +++ /dev/null @@ -1,38 +0,0 @@ -libWiiPy package -================ - -Subpackages ------------ - -.. toctree:: - :maxdepth: 4 - - libWiiPy.archive - libWiiPy.title - -Submodules ----------- - -libWiiPy.shared module ----------------------- - -.. automodule:: libWiiPy.shared - :members: - :undoc-members: - :show-inheritance: - -libWiiPy.types module ---------------------- - -.. automodule:: libWiiPy.types - :members: - :undoc-members: - :show-inheritance: - -Module contents ---------------- - -.. automodule:: libWiiPy - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/source/libWiiPy.title.rst b/docs/source/libWiiPy.title.md similarity index 59% rename from docs/source/libWiiPy.title.rst rename to docs/source/libWiiPy.title.md index 28f49c1..00d046d 100644 --- a/docs/source/libWiiPy.title.rst +++ b/docs/source/libWiiPy.title.md @@ -1,77 +1,78 @@ -libWiiPy.title package -====================== +# libWiiPy.title package -Submodules ----------- +## Submodules -libWiiPy.title.commonkeys module --------------------------------- +### libWiiPy.title.commonkeys module +```{eval-rst} .. automodule:: libWiiPy.title.commonkeys :members: :undoc-members: :show-inheritance: +``` -libWiiPy.title.content module ------------------------------ +### libWiiPy.title.content module +```{eval-rst} .. automodule:: libWiiPy.title.content :members: :undoc-members: :show-inheritance: +``` -libWiiPy.title.crypto module ----------------------------- +### libWiiPy.title.crypto module +```{eval-rst} .. automodule:: libWiiPy.title.crypto :members: :undoc-members: :show-inheritance: +``` +### libWiiPy.title.nus module -libWiiPy.title.nus module -------------------------- - +```{eval-rst} .. automodule:: libWiiPy.title.nus :members: :undoc-members: :show-inheritance: +``` +### libWiiPy.title.ticket module -libWiiPy.title.ticket module ----------------------------- - +```{eval-rst} .. automodule:: libWiiPy.title.ticket :members: :undoc-members: :show-inheritance: +``` +### libWiiPy.title.title module -libWiiPy.title.title module ---------------------------- - +```{eval-rst} .. automodule:: libWiiPy.title.title :members: :undoc-members: :show-inheritance: +``` +### libWiiPy.title.tmd module -libWiiPy.title.tmd module -------------------------- - +```{eval-rst} .. automodule:: libWiiPy.title.tmd :members: :undoc-members: :show-inheritance: +``` +### libWiiPy.title.wad module -libWiiPy.title.wad module -------------------------- - +```{eval-rst} .. automodule:: libWiiPy.title.wad :members: :undoc-members: :show-inheritance: +``` +## Module contents -Module contents ---------------- - +```{eval-rst} .. automodule:: libWiiPy.title :members: :undoc-members: :show-inheritance: +``` diff --git a/docs/source/modules.md b/docs/source/modules.md new file mode 100644 index 0000000..f47f684 --- /dev/null +++ b/docs/source/modules.md @@ -0,0 +1,7 @@ +# libWiiPy + +```{toctree} +:maxdepth: 4 + +libWiiPy +``` diff --git a/docs/source/modules.rst b/docs/source/modules.rst deleted file mode 100644 index 55f3b4b..0000000 --- a/docs/source/modules.rst +++ /dev/null @@ -1,7 +0,0 @@ -libWiiPy -======== - -.. toctree:: - :maxdepth: 4 - - libWiiPy diff --git a/src/libWiiPy/title/content.py b/src/libWiiPy/title/content.py index 6e4af43..bcb8d40 100644 --- a/src/libWiiPy/title/content.py +++ b/src/libWiiPy/title/content.py @@ -7,7 +7,7 @@ import io import sys import hashlib from typing import List -from ..types import ContentRecord +from ..types import _ContentRecord from .crypto import decrypt_content, encrypt_content @@ -18,20 +18,20 @@ class ContentRegion: Attributes ---------- - content_records : List[ContentRecord] + content_records : List[_ContentRecord] The content records for the content stored in the region. num_contents : int The total number of contents stored in the region. """ def __init__(self): - self.content_records: List[ContentRecord] = [] + self.content_records: List[_ContentRecord] = [] self.content_region_size: int = 0 # Size of the content region. self.num_contents: int = 0 # Number of contents in the content region. self.content_start_offsets: List[int] = [0] # The start offsets of each content in the content region. self.content_list: List[bytes] = [] - def load(self, content_region: bytes, content_records: List[ContentRecord]) -> None: + def load(self, content_region: bytes, content_records: List[_ContentRecord]) -> None: """ Loads the raw content region and builds a list of all the contents. @@ -39,7 +39,7 @@ class ContentRegion: ---------- content_region : bytes The raw data for the content region being loaded. - content_records : list[ContentRecord] + content_records : list[_ContentRecord] A list of ContentRecord objects detailing all contents contained in the region. """ self.content_records = content_records @@ -256,7 +256,7 @@ class ContentRegion: if (index + 1) > num_contents + 1: raise ValueError("You are trying to set the content at position " + str(index) + ", but no content " "exists at position " + str(index - 1) + "!") - self.content_records.append(ContentRecord(cid, index, content_type, content_size, content_hash)) + self.content_records.append(_ContentRecord(cid, index, content_type, content_size, content_hash)) # If it does, reassign the values in it. else: self.content_records[index].content_id = cid diff --git a/src/libWiiPy/title/tmd.py b/src/libWiiPy/title/tmd.py index c039473..edf5a35 100644 --- a/src/libWiiPy/title/tmd.py +++ b/src/libWiiPy/title/tmd.py @@ -7,7 +7,7 @@ import io import binascii import struct from typing import List -from ..types import ContentRecord +from ..types import _ContentRecord class TMD: @@ -52,7 +52,7 @@ class TMD: self.title_version: int = 0 # The version of the associated title. self.num_contents: int = 0 # The number of contents contained in the associated title. self.boot_index: int = 0 # The content index that contains the bootable executable. - self.content_records: List[ContentRecord] = [] + self.content_records: List[_ContentRecord] = [] def load(self, tmd: bytes) -> None: """ @@ -142,9 +142,9 @@ class TMD: tmd_data.seek(0x1E4 + (36 * content)) content_record_hdr = struct.unpack(">LHH4x4s20s", tmd_data.read(36)) self.content_records.append( - ContentRecord(int(content_record_hdr[0]), int(content_record_hdr[1]), - int(content_record_hdr[2]), int.from_bytes(content_record_hdr[3]), - binascii.hexlify(content_record_hdr[4]))) + _ContentRecord(int(content_record_hdr[0]), int(content_record_hdr[1]), + int(content_record_hdr[2]), int.from_bytes(content_record_hdr[3]), + binascii.hexlify(content_record_hdr[4]))) def dump(self) -> bytes: """ @@ -310,7 +310,7 @@ class TMD: case _: return "Unknown" - def get_content_record(self, record) -> ContentRecord: + def get_content_record(self, record) -> _ContentRecord: """ Gets the content record at the specified index. @@ -321,7 +321,7 @@ class TMD: Returns ------- - ContentRecord + _ContentRecord A ContentRecord object containing the data in the content record. """ if record < self.num_contents: diff --git a/src/libWiiPy/types.py b/src/libWiiPy/types.py index f898d77..07c6a40 100644 --- a/src/libWiiPy/types.py +++ b/src/libWiiPy/types.py @@ -4,7 +4,7 @@ from dataclasses import dataclass @dataclass -class ContentRecord: +class _ContentRecord: """ A content record object that contains the details of a content contained in a title. This information must match the content stored at the index in the record, or else the content will not decrypt properly, as the hash of the