Skip to content

chore: add documentation for content.rs and metadata.rs - #26

Merged
dastarruer merged 6 commits into
masterfrom
chore/add-docstrings
May 9, 2026
Merged

chore: add documentation for content.rs and metadata.rs#26
dastarruer merged 6 commits into
masterfrom
chore/add-docstrings

Conversation

@dastarruer

@dastarruer dastarruer commented May 9, 2026

Copy link
Copy Markdown
Owner

Closes #18.

Summary by CodeRabbit

  • Documentation
    • Improved documentation for EPUB content extraction and metadata reading, including clearer descriptions, usage examples, argument details, and error information to aid developers and maintainers.

Review Change Stack

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c0d447bb-8c07-47c4-ba2d-53c92e916ee8

📥 Commits

Reviewing files that changed from the base of the PR and between ee854b6 and bbd6507.

📒 Files selected for processing (1)
  • src-tauri/src/commands/content.rs

📝 Walkthrough

Walkthrough

Rustdoc comments are added to two command handler modules: content.rs receives documentation for the Resource struct, UrlInjector utility, and two public functions (get_epub_content_inner, get_resource); metadata.rs receives documentation for the Metadata struct and read_epub_metadata_inner function. All additions describe purpose, arguments, and error conditions without changing signatures or logic.

Changes

Documentation for EPUB Command Handlers

Layer / File(s) Summary
Resource Type and Methods
src-tauri/src/commands/content.rs
Resource struct documented as storing EPUB bytes and content-type; accessor methods bytes() and content_type() documented.
UrlInjector Struct and Methods
src-tauri/src/commands/content.rs
UrlInjector documented for injecting epub://localhost URLs into XHTML content; new() constructor and normalize_file_path() method documented with examples covering relative paths, parent traversal, and percent-encoding.
Content Extraction Functions
src-tauri/src/commands/content.rs
get_epub_content_inner() documented as extracting XHTML in canonical order; get_resource() documented for fetching EPUB resources by container path; both enumerate error conditions.
Metadata Type and Function
src-tauri/src/commands/metadata.rs
Metadata struct documented; read_epub_metadata_inner() documented to extract EPUB metadata with source argument and error cases (missing or malformed EPUB).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Poem

🐇 I nibble lines and leave a trail of notes,
Documenting bytes and injector quotes.
Resource and Metadata now sing in rhyme,
URLs normalized, one hop at a time.
Read the docs — the rabbit did the chores!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR successfully adds documentation to multiple methods in src-tauri/src/commands/content.rs (Resource, UrlInjector, get_resource, get_epub_content_inner) and src-tauri/src/commands/metadata.rs (Metadata, read_epub_metadata_inner), meeting the objective in issue #18 to provide documentation for undocumented methods.
Out of Scope Changes check ✅ Passed All changes are documentation additions directly related to issue #18's objective of adding docs to content.rs and metadata.rs; no unrelated functional changes or out-of-scope modifications are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title clearly and specifically describes the main change: adding documentation to content.rs and metadata.rs files, which aligns perfectly with the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/add-docstrings

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dastarruer
dastarruer force-pushed the chore/add-docstrings branch from d75266b to ee854b6 Compare May 9, 2026 17:58
@dastarruer

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (7)
src-tauri/src/commands/content.rs (5)

28-28: 💤 Low value

Use third-person present tense for method descriptions.

Per Rust documentation conventions, method descriptions should use third-person present tense ("Returns") rather than imperative mood ("Return").

📝 Suggested revisions
-    /// Return the raw bytes of the resource to be used in an HTTP response.
+    /// Returns the raw bytes of the resource to be used in an HTTP response.
     pub(crate) fn bytes(&self) -> &[u8] {
-    /// Return the content-type of the resource to be used in an HTTP response.
+    /// Returns the content-type of the resource to be used in an HTTP response.
     pub(crate) fn content_type(&self) -> &str {

Also applies to: 33-33

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src-tauri/src/commands/content.rs` at line 28, Update the Rust doc comments
for the relevant functions to use third‑person present tense (e.g., change
"Return the raw bytes of the resource to be used in an HTTP response." to
"Returns the raw bytes of the resource to be used in an HTTP response."). Locate
the docstrings above the functions referenced in this file (the docs around the
resource-returning methods in src-tauri/src/commands/content.rs) and change any
imperative "Return"/"Return(s)" phrasing to "Returns" to follow Rust
documentation conventions.

39-39: ⚡ Quick win

Fix typo: "URLS" should be "URLs".

📝 Suggested fix
-/// Struct to inject custom `epub://localhost` URLS into XHTML EPUB content.
+/// Struct to inject custom `epub://localhost` URLs into XHTML EPUB content.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src-tauri/src/commands/content.rs` at line 39, Update the doc comment that
reads "Struct to inject custom `epub://localhost` URLS into XHTML EPUB content."
to correct the typo by changing "URLS" to "URLs" in the comment directly above
the struct that injects custom epub URLs (the struct used to inject custom
`epub://localhost` URLs into XHTML EPUB content).

170-170: 💤 Low value

Use third-person present tense.

Per Rust documentation conventions, use "Extracts" instead of "Extract".

📝 Suggested revision
-/// Extract all XHTML content from an EPUB in canonical reading order.
+/// Extracts all XHTML content from an EPUB in canonical reading order.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src-tauri/src/commands/content.rs` at line 170, Change the function doc
comment that currently starts with "Extract all XHTML content from an EPUB in
canonical reading order." to use third-person present tense per Rust conventions
by replacing "Extract" with "Extracts"; update the doc comment immediately above
the corresponding function (the function documented by this comment) so the
first word is "Extracts".

208-208: 💤 Low value

Use third-person present tense.

Per Rust documentation conventions, use "Fetches" instead of "Fetch".

📝 Suggested revision
-/// Fetch an EPUB resource, given its absolute path within the container.
+/// Fetches an EPUB resource, given its absolute path within the container.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src-tauri/src/commands/content.rs` at line 208, Update the doc comment for
the EPUB resource function to use third-person present tense: replace "Fetch an
EPUB resource, given its absolute path within the container." with "Fetches an
EPUB resource, given its absolute path within the container." Locate the
docstring above the function that handles EPUB retrieval (the comment currently
starting "Fetch an EPUB resource...") and apply the single-word tense change to
conform to Rust documentation conventions.

105-105: 💤 Low value

Consider using third-person present tense.

For consistency with Rust documentation conventions, consider using "Converts" instead of "Convert".

📝 Suggested revision
-    /// Convert a relative path within the container to an absolute path, and
+    /// Converts a relative path within the container to an absolute path, and
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src-tauri/src/commands/content.rs` at line 105, Update the documentation
comment that begins "Convert a relative path within the container to an absolute
path, and" to use third-person present tense; change "Convert" to "Converts" (so
it reads "Converts a relative path within the container to an absolute path, and
..."). Locate the doc comment immediately above the related function in
src-tauri/src/commands/content.rs (the comment text shown) and make the
single-word tense change to keep Rust docs consistent.
src-tauri/src/commands/metadata.rs (2)

7-7: 💤 Low value

Consider using third-person present tense.

Rust documentation convention prefers third-person present tense for struct descriptions. Consider changing "Store" to "Stores".

📝 Suggested revision
-/// Store metadata of an EPUB.
+/// Stores metadata of an EPUB.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src-tauri/src/commands/metadata.rs` at line 7, Change the Rust doc comment
that currently reads "Store metadata of an EPUB." to third-person present tense
by making it "Stores metadata of an EPUB." — update the documentation string for
the item the comment documents (the doc comment shown in
src-tauri/src/commands/metadata.rs) so it follows Rust doc convention.

41-41: 💤 Low value

Improve grammar and follow Rust conventions.

The opening line has two minor issues:

  1. Missing the article "an" before "EPUB"
  2. Should use third-person present tense ("Extracts") per Rust documentation conventions
📝 Suggested revision
-/// Extract metadata from EPUB.
+/// Extracts metadata from an EPUB.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src-tauri/src/commands/metadata.rs` at line 41, Update the doc comment on the
EPUB metadata function to use Rust docs conventions and proper grammar: change
the sentence to third-person present tense and include the article, e.g.,
replace "Extract metadata from EPUB." with "Extracts metadata from an EPUB."
Locate the documentation comment above the function in
src-tauri/src/commands/metadata.rs (the doc string for the EPUB metadata
extractor, e.g., the comment immediately preceding the extract_metadata or
similar function) and make this single-line edit.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src-tauri/src/commands/content.rs`:
- Line 28: Update the Rust doc comments for the relevant functions to use
third‑person present tense (e.g., change "Return the raw bytes of the resource
to be used in an HTTP response." to "Returns the raw bytes of the resource to be
used in an HTTP response."). Locate the docstrings above the functions
referenced in this file (the docs around the resource-returning methods in
src-tauri/src/commands/content.rs) and change any imperative
"Return"/"Return(s)" phrasing to "Returns" to follow Rust documentation
conventions.
- Line 39: Update the doc comment that reads "Struct to inject custom
`epub://localhost` URLS into XHTML EPUB content." to correct the typo by
changing "URLS" to "URLs" in the comment directly above the struct that injects
custom epub URLs (the struct used to inject custom `epub://localhost` URLs into
XHTML EPUB content).
- Line 170: Change the function doc comment that currently starts with "Extract
all XHTML content from an EPUB in canonical reading order." to use third-person
present tense per Rust conventions by replacing "Extract" with "Extracts";
update the doc comment immediately above the corresponding function (the
function documented by this comment) so the first word is "Extracts".
- Line 208: Update the doc comment for the EPUB resource function to use
third-person present tense: replace "Fetch an EPUB resource, given its absolute
path within the container." with "Fetches an EPUB resource, given its absolute
path within the container." Locate the docstring above the function that handles
EPUB retrieval (the comment currently starting "Fetch an EPUB resource...") and
apply the single-word tense change to conform to Rust documentation conventions.
- Line 105: Update the documentation comment that begins "Convert a relative
path within the container to an absolute path, and" to use third-person present
tense; change "Convert" to "Converts" (so it reads "Converts a relative path
within the container to an absolute path, and ..."). Locate the doc comment
immediately above the related function in src-tauri/src/commands/content.rs (the
comment text shown) and make the single-word tense change to keep Rust docs
consistent.

In `@src-tauri/src/commands/metadata.rs`:
- Line 7: Change the Rust doc comment that currently reads "Store metadata of an
EPUB." to third-person present tense by making it "Stores metadata of an EPUB."
— update the documentation string for the item the comment documents (the doc
comment shown in src-tauri/src/commands/metadata.rs) so it follows Rust doc
convention.
- Line 41: Update the doc comment on the EPUB metadata function to use Rust docs
conventions and proper grammar: change the sentence to third-person present
tense and include the article, e.g., replace "Extract metadata from EPUB." with
"Extracts metadata from an EPUB." Locate the documentation comment above the
function in src-tauri/src/commands/metadata.rs (the doc string for the EPUB
metadata extractor, e.g., the comment immediately preceding the extract_metadata
or similar function) and make this single-line edit.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a7dfac7e-f4b7-4105-9489-eaed37204954

📥 Commits

Reviewing files that changed from the base of the PR and between 2cd7f3d and ee854b6.

📒 Files selected for processing (2)
  • src-tauri/src/commands/content.rs
  • src-tauri/src/commands/metadata.rs

@dastarruer dastarruer changed the title chore: add docs chore: add documentation for content.rs and metadata.rs May 9, 2026
@dastarruer
dastarruer merged commit c08bbd3 into master May 9, 2026
1 of 2 checks passed
@dastarruer
dastarruer deleted the chore/add-docstrings branch May 9, 2026 22:14
dastarruer added a commit that referenced this pull request May 9, 2026
Closes #18.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Documentation**
* Enhanced documentation across core modules to improve code clarity and
maintainability.

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/dastarruer/epub-editor/pull/26)

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add docs to src-tauri/src/commands/content.rs

1 participant