Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Hide full links in docs #29

Merged
merged 7 commits into from
Jun 12, 2024
Merged

Hide full links in docs #29

merged 7 commits into from
Jun 12, 2024

Conversation

Mews
Copy link
Contributor

@Mews Mews commented Jun 11, 2024

Description

Modified the sphinx config file to not include full paths when building the docs

Related Issue

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

📚 Documentation preview 📚: https://flask-utils--29.org.readthedocs.build/en/29/

Summary by CodeRabbit

  • Documentation

    • Updated API documentation to reflect the new usage of FlaskUtils class methods for error handling.
    • Added configuration option add_module_names = False for EPUB output in conf.py.
    • Revised exception references in the validate_params function's docstring.
  • Refactor

    • Updated internal references to FlaskUtils class and methods for improved readability and maintainability.

Copy link
Contributor

coderabbitai bot commented Jun 11, 2024

Walkthrough

This update refines the documentation and codebase of a Flask application by replacing full path references with relative paths for better readability. It includes changes to the api.rst, conf.py, decorators.py, and errors/__init__.py files, focusing on simplifying exception handling and documentation references.

Changes

Files/Paths Change Summaries
docs/source/api.rst Updated documentation to use FlaskUtils class methods directly for error handling setup.
docs/source/conf.py Added add_module_names = False configuration for EPUB output.
flask_utils/decorators.py Changed docstring in validate_params to raise BadRequestError instead of full path reference.
flask_utils/errors/__init__.py Updated references to FlaskUtils class and methods to use relative paths with ~ symbol.

Assessment against linked issues

Objective (Issue #10) Addressed Explanation
Refactor documentation to avoid full links

Poem

In the world of Flask, a change so bright,
Simplifying paths, making docs light.
FlaskUtils now stands clear and tall,
With shorter links, we heed the call.
A rabbit hops, in joy it sings,
For clarity, these updates bring.

Warning

Review ran into problems

Problems (1)
  • Git: Failed to clone repository. Please contact CodeRabbit support.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8b3ad07 and 2edd3d1.

Files selected for processing (1)
  • docs/source/conf.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • docs/source/conf.py

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 11, 2024
@Seluj78
Copy link
Owner

Seluj78 commented Jun 11, 2024

Oh wow I didn't think it would be that easy, nice one ! 🙌

I have found some full links still, they might be due to me hard-coding them, but here are the links to the preview build of your PR where I found them, ideally if you could fix those as well in the same PR it would be amazing !

https://flask-utils--29.org.readthedocs.build/en/29/api.html#custom-exceptions

https://flask-utils--29.org.readthedocs.build/en/29/api.html#module-flask_utils.decorators

https://flask-utils--29.org.readthedocs.build/en/29/api.html#flask_utils.errors._register_error_handlers

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2edd3d1 and 2ab6faa.

Files selected for processing (1)
  • docs/source/conf.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • docs/source/conf.py

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 11, 2024
@Mews
Copy link
Contributor Author

Mews commented Jun 11, 2024

Oops yeah I didn't realise that, I fixed that now

docs/source/api.rst Outdated Show resolved Hide resolved
flask_utils/errors/__init__.py Outdated Show resolved Hide resolved
Copy link
Contributor

@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 and nitpick comments (2)
flask_utils/decorators.py (2)

Line range hint 247-247: Improve exception handling by specifying the cause of the raised exceptions.

-            except BadRequest:
-                raise BadRequestError("The Json Body is malformed.")
+            except BadRequest as err:
+                raise BadRequestError("The Json Body is malformed.") from err

-            except UnsupportedMediaType:
-                raise BadRequestError(
+            except UnsupportedMediaType as err:
+                raise BadRequestError(
                    "The Content-Type header is missing or is not set to application/json, or the JSON body is missing."
                ) from err

Also applies to: 249-251


Line range hint 92-94: Simplify the nested if statements to enhance readability and maintainability.

-    if value in [None, "", [], {}]:
-        # Check if type is explicitly Optional or allow_empty is True
-        if _is_optional(type_hint) or allow_empty:
-            return True
+    if value in [None, "", [], {}] and (_is_optional(type_hint) or allow_empty):
+        return True
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2ab6faa and e3f9c6c.

Files selected for processing (3)
  • docs/source/api.rst (1 hunks)
  • flask_utils/decorators.py (1 hunks)
  • flask_utils/errors/init.py (1 hunks)
Files skipped from review due to trivial changes (2)
  • docs/source/api.rst
  • flask_utils/errors/init.py
Additional context used
Ruff
flask_utils/decorators.py

92-94: Use a single if statement instead of nested if statements (SIM102)


247-247: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling (B904)


249-251: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling (B904)

Additional comments not posted (1)
flask_utils/decorators.py (1)

189-189: Update the exception reference in the docstring to match the simplified usage.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 12, 2024
Seluj78
Seluj78 previously approved these changes Jun 12, 2024
Copy link
Owner

@Seluj78 Seluj78 left a comment

Choose a reason for hiding this comment

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

Amazing ! There's just your last commit that doesn't fit the linting. The title is too long :)

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e3f9c6c and c0cb9f6.

Files selected for processing (1)
  • docs/source/api.rst (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • docs/source/api.rst

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 12, 2024
@Mews
Copy link
Contributor Author

Mews commented Jun 12, 2024

Is it? I counted 69 characters but I'll shorten it

@Seluj78
Copy link
Owner

Seluj78 commented Jun 12, 2024

Also sphinx-lint detected some trailing whitespaces

@Mews
Copy link
Contributor Author

Mews commented Jun 12, 2024

Oh mb where are they, I can't see the logs

@Seluj78
Copy link
Owner

Seluj78 commented Jun 12, 2024

Oh mb where are they, I can't see the logs

No worries haha, that's why I recommend you install pre-commit like explained in CONTRIBUTING.md
Screenshot 2024-06-12 at 11 36 31

Screenshot 2024-06-12 at 11 36 39

@Mews
Copy link
Contributor Author

Mews commented Jun 12, 2024

I had it installed but I cleared my venv and I forgot :/ I'll fix it now

@Seluj78
Copy link
Owner

Seluj78 commented Jun 12, 2024

Don't forget to do pre-commit install and then pre-commit install --hook-type commit-msg

@Mews Mews dismissed stale reviews from coderabbitai[bot] and Seluj78 via 6e5fefc June 12, 2024 09:45
@Mews
Copy link
Contributor Author

Mews commented Jun 12, 2024

Done!

@Seluj78
Copy link
Owner

Seluj78 commented Jun 12, 2024

Weirdly, your commit still isn't passing. Do you want to try again or do you want me to do it ?

@Mews
Copy link
Contributor Author

Mews commented Jun 12, 2024

The commit message? Which one is failing I can change it again

@Seluj78
Copy link
Owner

Seluj78 commented Jun 12, 2024

This one weirdly

Screenshot 2024-06-12 at 11 50 36

@Mews
Copy link
Contributor Author

Mews commented Jun 12, 2024

Mhm that's definitely less than 72 characters
image

@Seluj78
Copy link
Owner

Seluj78 commented Jun 12, 2024

Want me to try ? Don't touch your branch I'll try and fix it if you're ok with it

@Mews
Copy link
Contributor Author

Mews commented Jun 12, 2024

Okay 👍

@Seluj78
Copy link
Owner

Seluj78 commented Jun 12, 2024

Hmm still trying to figure it out

Copy link
Contributor

@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 and nitpick comments (2)
flask_utils/decorators.py (2)

Line range hint 92-94: Refactor to use a single if statement.

- if not data:
-     raise BadRequestError("Missing json body.")
- if not isinstance(data, dict):
-     raise BadRequestError("JSON body must be a dict")
+ if not data or not isinstance(data, dict):
+     raise BadRequestError("Missing or invalid JSON body.")

This refactoring reduces the complexity of the code by combining related conditions, improving readability and maintainability.


Line range hint 247-247: Use the from keyword in exception handling.

- except BadRequest:
-     raise BadRequestError("The Json Body is malformed.")
+ except BadRequest as err:
+     raise BadRequestError("The Json Body is malformed.") from err

- except UnsupportedMediaType:
-     raise BadRequestError(
-         "The Content-Type header is missing or is not set to application/json, or the JSON body is missing."
-     )
+ except UnsupportedMediaType as err:
+     raise BadRequestError(
+         "The Content-Type header is missing or is not set to application/json, or the JSON body is missing."
+     ) from err

Using from err provides a clearer traceback and helps in debugging by linking the new exception to the original cause.

Also applies to: 249-251

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c0cb9f6 and c3899dd.

Files selected for processing (4)
  • docs/source/api.rst (1 hunks)
  • docs/source/conf.py (1 hunks)
  • flask_utils/decorators.py (1 hunks)
  • flask_utils/errors/init.py (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • docs/source/api.rst
  • docs/source/conf.py
  • flask_utils/errors/init.py
Additional context used
Ruff
flask_utils/decorators.py

92-94: Use a single if statement instead of nested if statements (SIM102)


247-247: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling (B904)


249-251: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling (B904)

Additional comments not posted (1)
flask_utils/decorators.py (1)

189-189: Update the docstring to reflect the correct exception.

- from flask_utils.errors.badrequest import BadRequestError
+ from flask_utils.errors import BadRequestError

This change aligns the import statement in the docstring with the actual import at the top of the file, ensuring consistency and correctness.

Likely invalid or redundant comment.

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c3899dd and cdc5dbe.

Files selected for processing (4)
  • docs/source/api.rst (1 hunks)
  • docs/source/conf.py (1 hunks)
  • flask_utils/decorators.py (1 hunks)
  • flask_utils/errors/init.py (1 hunks)
Files skipped from review as they are similar to previous changes (4)
  • docs/source/api.rst
  • docs/source/conf.py
  • flask_utils/decorators.py
  • flask_utils/errors/init.py

@Seluj78
Copy link
Owner

Seluj78 commented Jun 12, 2024

Here I fixed it by force. I removed the 72 chars limit. It's dumb anyway, and that way I will enforce it manually, or switch to using a better commit format (see #31)

@Seluj78 Seluj78 merged commit ca53126 into Seluj78:main Jun 12, 2024
13 of 14 checks passed
@Seluj78
Copy link
Owner

Seluj78 commented Jun 12, 2024

Thank you for the PR @Mews ! 😍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor documentation to avoid full links
2 participants