Skip to content

Docs API: Refactoring and refinement#406

Merged
amotl merged 1 commit intomainfrom
docs-api-refine
Apr 14, 2025
Merged

Docs API: Refactoring and refinement#406
amotl merged 1 commit intomainfrom
docs-api-refine

Conversation

@amotl
Copy link
Copy Markdown
Member

@amotl amotl commented Apr 14, 2025

About

Giving metadata a dedicated slot within the response, for both domains settings vs. functions.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 14, 2025

Walkthrough

The pull request refactors documentation and settings handling within the toolkit. In the CLI components, error logging was updated to use logger.exception for richer debugging information. The documentation retrieval process is now centered around a new DocsItem data class—replacing a static URL—thereby encapsulating metadata and providing a dedicated fetch method. In settings extraction, the code now leverages this new structure with adjustments in formatting and response handling. Test assertions were also revised to validate the new nested output structure.

Changes

File(s) Change Summary
cratedb_toolkit/docs/cli.py Replaced logger.error(msg) with logger.exception(msg) in both functions for enhanced error logging (including stack traces) before raising click.ClickException.
cratedb_toolkit/docs/functions.py
cratedb_toolkit/docs/model.py
Introduced the DocsItem data class in model.py with attributes for created, generator, and source_url plus a fetch method; updated functions.py to use DocsItem (renamed from DOCS_URL) for documentation metadata and fetching logic.
cratedb_toolkit/docs/settings.py Replaced DOCS_URL with a DocsItem instance; modified the OutputFormatter methods to access self.thing["settings"]; introduced a new SettingsResponse dataclass; updated SettingsExtractor to store the extracted settings and reference the new metadata structure.
tests/docs/test_cli.py Adjusted assertion checks for both JSON and YAML outputs by moving the expected data under the settings key, reflecting the restructured output format.
doc/docs-api.md Updated documentation to specify "scalar functions" and added references to "settings"; reorganized settings output structure and included a new "source_url" field in metadata.

Sequence Diagram(s)

sequenceDiagram
    participant CLI_Function
    participant Logger
    participant ClickHandler

    CLI_Function->>Logger: Log error with logger.exception(msg)
    Logger-->>CLI_Function: Returns detailed error (stack trace)
    CLI_Function->>ClickHandler: Raise ClickException
Loading
sequenceDiagram
    participant User
    participant SettingsExtractor
    participant DOCS_ITEM
    participant Logger
    participant OutputFormatter

    User->>SettingsExtractor: Request settings extraction
    SettingsExtractor->>DOCS_ITEM: Invoke fetch()
    DOCS_ITEM-->>SettingsExtractor: Return documentation content
    alt Successful fetch
        SettingsExtractor->>OutputFormatter: Process and format settings
        OutputFormatter-->>User: Return formatted settings data
    else Fetch failure
        SettingsExtractor->>Logger: Log exception via logger.exception
        SettingsExtractor->>User: Raise ClickException with error details
    end
Loading

Poem

Oh, I’m a coding bunny on the run,
Hopping through changes, having fun!
Docs and settings now sing a clearer tune,
With exceptions and metadata in bloom.
Leaping high with refactored delight—
Code so fresh, my heart is light! 🐰💻

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
cratedb_toolkit/docs/model.py (1)

1-22: 🛠️ Refactor suggestion

Good addition of the DocsItem data class for documentation metadata management.

This new file and class bring better structure to documentation item handling by encapsulating metadata and source URL in a dedicated class. The fetch method provides centralized HTTP request handling with proper timeout settings.

Two suggestions for improvement:

  1. Consider adding explicit exception handling in the fetch method to handle connection errors:
def fetch(self) -> str:
-    response = requests.get(self.source_url, timeout=10)
-    if response.status_code != 200:
-        logger.error(
-            f"Failed to fetch documentation from {self.source_url}: HTTP {response.status_code}\n{response.text}"
-        )
-    return response.text
+    try:
+        response = requests.get(self.source_url, timeout=10)
+        if response.status_code != 200:
+            logger.error(
+                f"Failed to fetch documentation from {self.source_url}: HTTP {response.status_code}\n{response.text}"
+            )
+        return response.text
+    except requests.RequestException as e:
+        logger.error(f"Failed to fetch documentation from {self.source_url}: {e}")
+        return ""
  1. Consider returning None or raising an exception when the request fails, rather than returning potentially invalid content:
def fetch(self) -> str:
    response = requests.get(self.source_url, timeout=10)
    if response.status_code != 200:
        logger.error(
            f"Failed to fetch documentation from {self.source_url}: HTTP {response.status_code}\n{response.text}"
        )
-        return response.text
+        return ""  # or raise an exception
+    return response.text
🧹 Nitpick comments (5)
cratedb_toolkit/docs/settings.py (5)

35-39: Global DOCS_ITEM creation is fine, but consider clarifying the ephemeral timestamp.
Using dt.datetime.now().isoformat() ensures consistent logging. However, if the module is reloaded repeatedly, the creation time can differ across runs. A brief comment clarifying this behavior might help maintainers.


59-59: Consider handling non-200 responses more robustly.
Although DocsItem.fetch() logs an error upon a non-200 response, the code continues with whatever content is returned. As an optional improvement, raise an exception to catch failed fetches early.

For example, in cratedb_toolkit/docs/model.py (unmodified in this PR), you could do:

 def fetch(self) -> str:
     response = requests.get(self.source_url, timeout=10)
     if response.status_code != 200:
+        logger.error(
+            f"Failed to fetch documentation from {self.source_url}: "
+            f"HTTP {response.status_code}\n{response.text}"
+        )
+        response.raise_for_status()  # Raise an exception instead of returning partial data
     return response.text

641-641: Guard against missing "settings" key in to_markdown.
If self.thing is empty, referencing self.thing["settings"] may cause a KeyError. You could do the following to avoid potential runtime errors:

-def to_markdown(self):
-    return write_markdown_table(self.thing["settings"])
+def to_markdown(self):
+    settings_data = self.thing.get("settings", {})
+    return write_markdown_table(settings_data)

650-650: Likewise, avoid KeyError in to_sql.
Encapsulate the same guard to safely handle absent 'settings' entries:

-def to_sql(self):
-    return write_sql_statements(self.thing["settings"])
+def to_sql(self):
+    settings_data = self.thing.get("settings", {})
+    return write_sql_statements(settings_data)

698-699: Generating SQL statements then synchronizing self.thing with self.response is logical.
You might consider exclusively relying on self.response to reduce duplication, but the current approach is valid and preserves backward compatibility.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4acd877 and a65f6f5.

📒 Files selected for processing (5)
  • cratedb_toolkit/docs/cli.py (2 hunks)
  • cratedb_toolkit/docs/functions.py (3 hunks)
  • cratedb_toolkit/docs/model.py (1 hunks)
  • cratedb_toolkit/docs/settings.py (8 hunks)
  • tests/docs/test_cli.py (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
cratedb_toolkit/docs/functions.py (2)
cratedb_toolkit/docs/model.py (2)
  • DocsItem (10-21)
  • fetch (15-21)
cratedb_toolkit/docs/util.py (1)
  • GenericProcessor (9-61)
cratedb_toolkit/docs/settings.py (4)
cratedb_toolkit/docs/model.py (2)
  • DocsItem (10-21)
  • fetch (15-21)
cratedb_toolkit/docs/cli.py (1)
  • settings (98-112)
cratedb_toolkit/docs/functions.py (2)
  • to_dict (36-43)
  • to_dict (65-72)
cratedb_toolkit/util/format.py (1)
  • to_dict (65-66)
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: Generic: Python 3.12 on OS ubuntu-latest
  • GitHub Check: Kinesis: Python 3.12 on OS ubuntu-latest
  • GitHub Check: Generic: Python 3.9 on OS ubuntu-latest
  • GitHub Check: Kinesis: Python 3.9 on OS ubuntu-latest
  • GitHub Check: CFR: Python 3.12 on OS ubuntu-latest
  • GitHub Check: Generic: Python 3.8 on OS ubuntu-latest
  • GitHub Check: CFR for OS windows-latest
  • GitHub Check: build-and-test
  • GitHub Check: CFR for OS ubuntu-latest
  • GitHub Check: CFR for OS macos-latest
  • GitHub Check: CFR for OS macos-13
🔇 Additional comments (19)
cratedb_toolkit/docs/cli.py (2)

84-84: Great improvement to error logging.

Changing logger.error to logger.exception will capture the full exception traceback, which is extremely helpful for debugging. This change enhances error observability while maintaining the same behavior for end users.


111-111: Great improvement to error logging.

Similar to the previous change, using logger.exception here ensures the full exception details are logged for the settings extraction process.

tests/docs/test_cli.py (2)

28-28: Test updated to match new nested response structure.

The test has been correctly updated to verify the new response structure, where settings data is now nested under a dedicated "settings" key. This aligns with the PR objective of giving metadata a dedicated slot.


93-93: Test updated to match new nested response structure.

The YAML format test has been correctly updated to match the same nested structure pattern as the JSON test, maintaining consistency across output formats.

cratedb_toolkit/docs/functions.py (4)

13-13: Good addition of the new model import.

Importing the newly created DocsItem class is necessary for the refactoring approach.


19-23: Good replacement of string constant with DocsItem instance.

Replacing the simple string URL with a structured DocsItem instance improves code organization and allows for additional metadata to be associated with the documentation source.


48-48: Good update to the type of the meta field.

Updating the meta field type from a dictionary to the DocsItem class aligns with the new approach for handling documentation metadata.


110-110: Good use of the DocsItem fetch method.

Using DOCS_ITEM.fetch() centralizes the HTTP request logic in the DocsItem class, which is a good practice for code maintainability.

cratedb_toolkit/docs/settings.py (11)

16-16: Import usage is appropriate.
The import from datetime appears correctly used below for constructing the created timestamp.


26-26: Importing DocsItem is correct.
This import aligns with the new approach to fetch documentation metadata via DocsItem.


53-53: Logging the source URL is helpful.
Good to see the log referencing DOCS_ITEM.source_url, making troubleshooting easier.


63-63: Parsing payload with BeautifulSoup is straightforward.
If payload is empty, you'll simply parse an empty document, which is safe in this context.


653-653: Using @dataclasses.dataclass is a good move.
This aligns with Pythonic best practices for structured data handling.


654-658: SettingsResponse fields are well-defined.
Encapsulating the doc metadata (meta) and extracted settings in a single response object clarifies responsibility.


660-668: Returning dataclasses.asdict(self) is straightforward and reliable.
This approach simplifies conversions without manual dictionary assembly.


682-682: Attaching SettingsResponse to SettingsExtractor is seamless.
This ensures all relevant data (including metadata) is readily available for rendering.


693-694: Storing extracted settings in response is consistent.
Replacing direct local usage of extract_cratedb_settings() with self.response.settings centralizes data handling in the dataclass.


696-696: Conditional check of self.response.settings is prudent.
Graceful handling of an empty result is important for debugging.


721-725: Runtime configurability log message is clear and informative.
Good to see the final count, helping users quickly confirm coverage.

@amotl amotl force-pushed the docs-api-refine branch from a65f6f5 to 2247886 Compare April 14, 2025 09:00
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
cratedb_toolkit/docs/model.py (1)

19-26: Consider adding error retry logic to the fetch method.

The fetch method correctly handles HTTP errors, but network requests can fail due to transient issues.

def fetch(self) -> str:
-    response = requests.get(self.source_url, timeout=10)
-    if response.status_code != 200:
-        logger.error(
-            f"Failed to fetch documentation from {self.source_url}: HTTP {response.status_code}\n{response.text}"
-        )
-        response.raise_for_status()
-    return response.text
+    max_retries = 3
+    retry_delay = 1
+    
+    for attempt in range(max_retries):
+        try:
+            response = requests.get(self.source_url, timeout=10)
+            if response.status_code != 200:
+                logger.error(
+                    f"Failed to fetch documentation from {self.source_url}: HTTP {response.status_code}\n{response.text}"
+                )
+                response.raise_for_status()
+            return response.text
+        except (requests.RequestException) as e:
+            if attempt < max_retries - 1:
+                logger.warning(f"Fetch attempt {attempt + 1} failed, retrying in {retry_delay}s: {str(e)}")
+                time.sleep(retry_delay)
+                retry_delay *= 2  # Exponential backoff
+            else:
+                logger.error(f"Failed to fetch after {max_retries} attempts: {str(e)}")
+                raise

Don't forget to add import time at the top of the file if you implement this change.

The static analysis hints indicate a lack of test coverage for this new class. Consider adding unit tests to verify both the success and error paths of the fetch method.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 19-22: cratedb_toolkit/docs/model.py#L19-L22
Added lines #L19 - L22 were not covered by tests


[warning] 25-26: cratedb_toolkit/docs/model.py#L25-L26
Added lines #L25 - L26 were not covered by tests

doc/docs-api.md (2)

79-89: Assess metadata consistency for stats.enabled.
The metadata for stats.enabled is comprehensive; however, there is noticeable overlap between the "raw_description" and "purpose" fields. Consider consolidating the shared details to avoid redundancy, or ensure that each field serves a distinct purpose in downstream processing.


90-102: Verify consistency in stats.jobs_log_size metadata.
Similar to stats.enabled, the metadata for stats.jobs_log_size contains overlapping content in the "raw_description" and "purpose" fields. It may be beneficial to review whether this duplication is intentional or if a streamlined approach could improve clarity.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a65f6f5 and 2247886.

📒 Files selected for processing (6)
  • cratedb_toolkit/docs/cli.py (2 hunks)
  • cratedb_toolkit/docs/functions.py (3 hunks)
  • cratedb_toolkit/docs/model.py (1 hunks)
  • cratedb_toolkit/docs/settings.py (8 hunks)
  • doc/docs-api.md (4 hunks)
  • tests/docs/test_cli.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/docs/test_cli.py
🧰 Additional context used
🧬 Code Graph Analysis (1)
cratedb_toolkit/docs/functions.py (2)
cratedb_toolkit/docs/model.py (2)
  • DocsItem (10-26)
  • fetch (19-26)
cratedb_toolkit/docs/util.py (1)
  • GenericProcessor (9-61)
🪛 GitHub Check: codecov/patch
cratedb_toolkit/docs/model.py

[warning] 1-2: cratedb_toolkit/docs/model.py#L1-L2
Added lines #L1 - L2 were not covered by tests


[warning] 4-4: cratedb_toolkit/docs/model.py#L4
Added line #L4 was not covered by tests


[warning] 6-6: cratedb_toolkit/docs/model.py#L6
Added line #L6 was not covered by tests


[warning] 9-10: cratedb_toolkit/docs/model.py#L9-L10
Added lines #L9 - L10 were not covered by tests


[warning] 15-17: cratedb_toolkit/docs/model.py#L15-L17
Added lines #L15 - L17 were not covered by tests


[warning] 19-22: cratedb_toolkit/docs/model.py#L19-L22
Added lines #L19 - L22 were not covered by tests


[warning] 25-26: cratedb_toolkit/docs/model.py#L25-L26
Added lines #L25 - L26 were not covered by tests

cratedb_toolkit/docs/settings.py

[warning] 16-16: cratedb_toolkit/docs/settings.py#L16
Added line #L16 was not covered by tests


[warning] 26-26: cratedb_toolkit/docs/settings.py#L26
Added line #L26 was not covered by tests


[warning] 35-35: cratedb_toolkit/docs/settings.py#L35
Added line #L35 was not covered by tests


[warning] 53-53: cratedb_toolkit/docs/settings.py#L53
Added line #L53 was not covered by tests


[warning] 59-59: cratedb_toolkit/docs/settings.py#L59
Added line #L59 was not covered by tests


[warning] 63-63: cratedb_toolkit/docs/settings.py#L63
Added line #L63 was not covered by tests


[warning] 641-642: cratedb_toolkit/docs/settings.py#L641-L642
Added lines #L641 - L642 were not covered by tests


[warning] 651-652: cratedb_toolkit/docs/settings.py#L651-L652
Added lines #L651 - L652 were not covered by tests


[warning] 655-658: cratedb_toolkit/docs/settings.py#L655-L658
Added lines #L655 - L658 were not covered by tests


[warning] 662-662: cratedb_toolkit/docs/settings.py#L662
Added line #L662 was not covered by tests


[warning] 669-669: cratedb_toolkit/docs/settings.py#L669
Added line #L669 was not covered by tests


[warning] 684-684: cratedb_toolkit/docs/settings.py#L684
Added line #L684 was not covered by tests


[warning] 696-696: cratedb_toolkit/docs/settings.py#L696
Added line #L696 was not covered by tests


[warning] 698-698: cratedb_toolkit/docs/settings.py#L698
Added line #L698 was not covered by tests


[warning] 700-701: cratedb_toolkit/docs/settings.py#L700-L701
Added lines #L700 - L701 were not covered by tests


[warning] 723-725: cratedb_toolkit/docs/settings.py#L723-L725
Added lines #L723 - L725 were not covered by tests

cratedb_toolkit/docs/cli.py

[warning] 84-84: cratedb_toolkit/docs/cli.py#L84
Added line #L84 was not covered by tests


[warning] 111-111: cratedb_toolkit/docs/cli.py#L111
Added line #L111 was not covered by tests

cratedb_toolkit/docs/functions.py

[warning] 13-13: cratedb_toolkit/docs/functions.py#L13
Added line #L13 was not covered by tests


[warning] 19-19: cratedb_toolkit/docs/functions.py#L19
Added line #L19 was not covered by tests


[warning] 48-48: cratedb_toolkit/docs/functions.py#L48
Added line #L48 was not covered by tests


[warning] 110-110: cratedb_toolkit/docs/functions.py#L110
Added line #L110 was not covered by tests

⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: build-and-publish
  • GitHub Check: Kinesis: Python 3.12 on OS ubuntu-latest
  • GitHub Check: Kinesis: Python 3.9 on OS ubuntu-latest
  • GitHub Check: Generic: Python 3.12 on OS ubuntu-latest
  • GitHub Check: Generic: Python 3.9 on OS ubuntu-latest
  • GitHub Check: CFR for OS windows-latest
  • GitHub Check: Generic: Python 3.8 on OS ubuntu-latest
  • GitHub Check: CFR for OS ubuntu-latest
  • GitHub Check: CFR for OS macos-13
🔇 Additional comments (21)
cratedb_toolkit/docs/model.py (2)

1-7: Appropriate imports and logger setup.

The necessary modules for dataclasses and HTTP requests are properly imported, and a module-level logger is correctly initialized.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 1-2: cratedb_toolkit/docs/model.py#L1-L2
Added lines #L1 - L2 were not covered by tests


[warning] 4-4: cratedb_toolkit/docs/model.py#L4
Added line #L4 was not covered by tests


[warning] 6-6: cratedb_toolkit/docs/model.py#L6
Added line #L6 was not covered by tests


9-18: Well-structured data class for documentation metadata.

The DocsItem class is well-designed to encapsulate documentation metadata, with appropriate fields for creation timestamp, generator info, and source URL.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 9-10: cratedb_toolkit/docs/model.py#L9-L10
Added lines #L9 - L10 were not covered by tests


[warning] 15-17: cratedb_toolkit/docs/model.py#L15-L17
Added lines #L15 - L17 were not covered by tests

cratedb_toolkit/docs/cli.py (2)

84-84: Improved error logging using logger.exception.

Changing from logger.error to logger.exception is a good improvement as it will include the full exception traceback in the log, providing more context for debugging.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 84-84: cratedb_toolkit/docs/cli.py#L84
Added line #L84 was not covered by tests


111-111: Improved error logging using logger.exception.

Same valuable improvement as in the functions handler, capturing the full exception traceback in the log.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 111-111: cratedb_toolkit/docs/cli.py#L111
Added line #L111 was not covered by tests

cratedb_toolkit/docs/functions.py (4)

13-13: Appropriate import of the new DocsItem class.

The import statement is correctly added to incorporate the new DocsItem class from the model module.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 13-13: cratedb_toolkit/docs/functions.py#L13
Added line #L13 was not covered by tests


19-23: Well-structured DocsItem initialization.

The DOCS_ITEM constant is properly initialized with all required metadata. Using a DocsItem instance instead of a raw URL string improves encapsulation and maintainability.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 19-19: cratedb_toolkit/docs/functions.py#L19
Added line #L19 was not covered by tests


48-48: Updated FunctionRegistry to use DocsItem.

The meta field correctly adopts the new DocsItem type, enhancing type safety and readability.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 48-48: cratedb_toolkit/docs/functions.py#L48
Added line #L48 was not covered by tests


110-110: Updated document fetch mechanism.

The fetch operation now properly uses the DocsItem.fetch() method, centralizing the HTTP request logic and improving maintainability.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 110-110: cratedb_toolkit/docs/functions.py#L110
Added line #L110 was not covered by tests

cratedb_toolkit/docs/settings.py (8)

16-16: Appropriate imports for the refactored code.

The datetime module and DocsItem class imports have been correctly added to support the changes.

Also applies to: 26-26

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 16-16: cratedb_toolkit/docs/settings.py#L16
Added line #L16 was not covered by tests


35-39: Well-structured DocsItem initialization.

Similar to functions.py, DOCS_ITEM is properly initialized with all necessary metadata, ensuring consistency across the codebase.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 35-35: cratedb_toolkit/docs/settings.py#L35
Added line #L35 was not covered by tests


53-53: Updated documentation fetching and processing.

The extract_cratedb_settings function correctly uses the new DOCS_ITEM for logging and fetching documentation content, maintaining consistency with the refactoring.

Also applies to: 59-59, 63-63

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 53-53: cratedb_toolkit/docs/settings.py#L53
Added line #L53 was not covered by tests


641-642: Updated OutputFormatter to work with nested structure.

The OutputFormatter methods now correctly access settings through the nested structure with self.thing.get("settings", {}), which is consistent with the new response format.

Also applies to: 651-652

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 641-642: cratedb_toolkit/docs/settings.py#L641-L642
Added lines #L641 - L642 were not covered by tests


655-670: Well-designed SettingsResponse data class.

The new SettingsResponse class properly encapsulates metadata and settings, following the same pattern as in the functions module. The to_dict method ensures consistent serialization.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 655-658: cratedb_toolkit/docs/settings.py#L655-L658
Added lines #L655 - L658 were not covered by tests


[warning] 662-662: cratedb_toolkit/docs/settings.py#L662
Added line #L662 was not covered by tests


[warning] 669-669: cratedb_toolkit/docs/settings.py#L669
Added line #L669 was not covered by tests


684-684: Added SettingsResponse field to SettingsExtractor.

The response field properly integrates the new SettingsResponse class into the SettingsExtractor.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 684-684: cratedb_toolkit/docs/settings.py#L684
Added line #L684 was not covered by tests


696-701: Updated acquire method to use new response structure.

The acquire method now correctly stores extracted settings in the response object and converts it to a dictionary for the thing attribute, maintaining the expected interface while improving internal structure.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 696-696: cratedb_toolkit/docs/settings.py#L696
Added line #L696 was not covered by tests


[warning] 698-698: cratedb_toolkit/docs/settings.py#L698
Added line #L698 was not covered by tests


[warning] 700-701: cratedb_toolkit/docs/settings.py#L700-L701
Added lines #L700 - L701 were not covered by tests


723-727: Updated render method to use new response structure.

The render method now correctly accesses settings through the response object, ensuring consistency with the refactored data structure.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 723-725: cratedb_toolkit/docs/settings.py#L723-L725
Added lines #L723 - L725 were not covered by tests

doc/docs-api.md (5)

14-15: Enhanced clarity for function extraction.
The updated description now clearly specifies that the tool extracts [scalar functions] rather than a generic set of functions, which enhances user understanding. Please ensure that the reference defined later in the document (line 108) correctly resolves to the intended documentation.


28-32: Updated functions metadata.
The meta block now includes a new "source_url" field alongside the "created" timestamp and "generator". This addition improves traceability to the original documentation source. Verify that the URL (line 31) is correct and that the timestamp format remains consistent with your standards.


56-57: Refined settings extraction description.
The change to specify [settings] in the description clarifies that the tool extracts settings-specific documentation. This clearer delineation should help users better understand the output structure.


73-77: Updated settings metadata.
The settings meta block now introduces a "source_url" that points to the CrateDB cluster configuration documentation. Confirm that the URL (line 76) accurately targets the intended resource and that the timestamp format matches the one used in the functions metadata.


108-109: New reference links added.
The document now includes explicit reference definitions for [scalar functions] and [settings], which will help users quickly navigate to the relevant CrateDB documentation. Ensure these links remain accurate as the documentation evolves.

@amotl amotl marked this pull request as ready for review April 14, 2025 09:07
@amotl amotl merged commit 57163d5 into main Apr 14, 2025
19 checks passed
@amotl amotl deleted the docs-api-refine branch April 14, 2025 09:07
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.

1 participant