Rewrote all docs in Markdown instead of the default reST

This commit is contained in:
Campbell 2024-06-25 22:57:09 -04:00
parent 53e098ca9b
commit df1ed559ef
Signed by: NinjaCheetah
GPG Key ID: B547958AF96ED344
11 changed files with 110 additions and 119 deletions

15
docs/source/index.md Normal file
View File

@ -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](<project:#genindex>)
* [Module Index](<project:#modules>)
* <project:#search>

View File

@ -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`

View File

@ -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 .. automodule:: libWiiPy.archive.ash
:members: :members:
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
```
### libWiiPy.archive.u8 module
libWiiPy.archive.u8 module ```{eval-rst}
--------------------------
.. automodule:: libWiiPy.archive.u8 .. automodule:: libWiiPy.archive.u8
:members: :members:
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
```
## Module contents
Module contents ```{eval-rst}
---------------
.. automodule:: libWiiPy.archive .. automodule:: libWiiPy.archive
:members: :members:
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
```

34
docs/source/libWiiPy.md Normal file
View File

@ -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:
```

View File

@ -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:

View File

@ -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 .. automodule:: libWiiPy.title.commonkeys
:members: :members:
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
```
libWiiPy.title.content module ### libWiiPy.title.content module
-----------------------------
```{eval-rst}
.. automodule:: libWiiPy.title.content .. automodule:: libWiiPy.title.content
:members: :members:
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
```
libWiiPy.title.crypto module ### libWiiPy.title.crypto module
----------------------------
```{eval-rst}
.. automodule:: libWiiPy.title.crypto .. automodule:: libWiiPy.title.crypto
:members: :members:
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
```
### libWiiPy.title.nus module
libWiiPy.title.nus module ```{eval-rst}
-------------------------
.. automodule:: libWiiPy.title.nus .. automodule:: libWiiPy.title.nus
:members: :members:
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
```
### libWiiPy.title.ticket module
libWiiPy.title.ticket module ```{eval-rst}
----------------------------
.. automodule:: libWiiPy.title.ticket .. automodule:: libWiiPy.title.ticket
:members: :members:
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
```
### libWiiPy.title.title module
libWiiPy.title.title module ```{eval-rst}
---------------------------
.. automodule:: libWiiPy.title.title .. automodule:: libWiiPy.title.title
:members: :members:
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
```
### libWiiPy.title.tmd module
libWiiPy.title.tmd module ```{eval-rst}
-------------------------
.. automodule:: libWiiPy.title.tmd .. automodule:: libWiiPy.title.tmd
:members: :members:
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
```
### libWiiPy.title.wad module
libWiiPy.title.wad module ```{eval-rst}
-------------------------
.. automodule:: libWiiPy.title.wad .. automodule:: libWiiPy.title.wad
:members: :members:
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
```
## Module contents
Module contents ```{eval-rst}
---------------
.. automodule:: libWiiPy.title .. automodule:: libWiiPy.title
:members: :members:
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
```

7
docs/source/modules.md Normal file
View File

@ -0,0 +1,7 @@
# libWiiPy
```{toctree}
:maxdepth: 4
libWiiPy
```

View File

@ -1,7 +0,0 @@
libWiiPy
========
.. toctree::
:maxdepth: 4
libWiiPy

View File

@ -7,7 +7,7 @@ import io
import sys import sys
import hashlib import hashlib
from typing import List from typing import List
from ..types import ContentRecord from ..types import _ContentRecord
from .crypto import decrypt_content, encrypt_content from .crypto import decrypt_content, encrypt_content
@ -18,20 +18,20 @@ class ContentRegion:
Attributes Attributes
---------- ----------
content_records : List[ContentRecord] content_records : List[_ContentRecord]
The content records for the content stored in the region. The content records for the content stored in the region.
num_contents : int num_contents : int
The total number of contents stored in the region. The total number of contents stored in the region.
""" """
def __init__(self): 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.content_region_size: int = 0 # Size of the content region.
self.num_contents: int = 0 # Number of contents in 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_start_offsets: List[int] = [0] # The start offsets of each content in the content region.
self.content_list: List[bytes] = [] 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. Loads the raw content region and builds a list of all the contents.
@ -39,7 +39,7 @@ class ContentRegion:
---------- ----------
content_region : bytes content_region : bytes
The raw data for the content region being loaded. 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. A list of ContentRecord objects detailing all contents contained in the region.
""" """
self.content_records = content_records self.content_records = content_records
@ -256,7 +256,7 @@ class ContentRegion:
if (index + 1) > num_contents + 1: if (index + 1) > num_contents + 1:
raise ValueError("You are trying to set the content at position " + str(index) + ", but no content " raise ValueError("You are trying to set the content at position " + str(index) + ", but no content "
"exists at position " + str(index - 1) + "!") "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. # If it does, reassign the values in it.
else: else:
self.content_records[index].content_id = cid self.content_records[index].content_id = cid

View File

@ -7,7 +7,7 @@ import io
import binascii import binascii
import struct import struct
from typing import List from typing import List
from ..types import ContentRecord from ..types import _ContentRecord
class TMD: class TMD:
@ -52,7 +52,7 @@ class TMD:
self.title_version: int = 0 # The version of the associated title. 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.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.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: def load(self, tmd: bytes) -> None:
""" """
@ -142,9 +142,9 @@ class TMD:
tmd_data.seek(0x1E4 + (36 * content)) tmd_data.seek(0x1E4 + (36 * content))
content_record_hdr = struct.unpack(">LHH4x4s20s", tmd_data.read(36)) content_record_hdr = struct.unpack(">LHH4x4s20s", tmd_data.read(36))
self.content_records.append( self.content_records.append(
ContentRecord(int(content_record_hdr[0]), int(content_record_hdr[1]), _ContentRecord(int(content_record_hdr[0]), int(content_record_hdr[1]),
int(content_record_hdr[2]), int.from_bytes(content_record_hdr[3]), int(content_record_hdr[2]), int.from_bytes(content_record_hdr[3]),
binascii.hexlify(content_record_hdr[4]))) binascii.hexlify(content_record_hdr[4])))
def dump(self) -> bytes: def dump(self) -> bytes:
""" """
@ -310,7 +310,7 @@ class TMD:
case _: case _:
return "Unknown" return "Unknown"
def get_content_record(self, record) -> ContentRecord: def get_content_record(self, record) -> _ContentRecord:
""" """
Gets the content record at the specified index. Gets the content record at the specified index.
@ -321,7 +321,7 @@ class TMD:
Returns Returns
------- -------
ContentRecord _ContentRecord
A ContentRecord object containing the data in the content record. A ContentRecord object containing the data in the content record.
""" """
if record < self.num_contents: if record < self.num_contents:

View File

@ -4,7 +4,7 @@ from dataclasses import dataclass
@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 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 the content stored at the index in the record, or else the content will not decrypt properly, as the hash of the