Skip to content

Conversation

@yyc12345
Copy link
Contributor

@yyc12345 yyc12345 commented May 9, 2025

  • change project layout to make it suit for Rust best practices.
    • add lib.rs to manage modules, rather than declare them in main.rs.
    • use module folder to manage project.
  • rename cli_args to cli to make it correspond with its meaning (not only cli arguments, but also all things involving cli).
  • move cli executor into cli module to make main.rs be clean.
  • use Rust document syntax to make comments for struct and fields, instead of normal comments.

Summary by Sourcery

Refactor the project structure to follow Rust best practices by reorganizing modules, improving code organization, and enhancing documentation.

New Features:

  • Add lib.rs to manage project modules

Enhancements:

  • Restructure project layout to improve module management
  • Rename cli_args module to cli for broader scope
  • Move CLI execution logic into a centralized function
  • Improve Rust documentation syntax for structs and fields

Chores:

  • Reorganize file structure to group related modules
  • Update import paths to reflect new module structure

@deepin-ci-robot
Copy link

Hi @yyc12345. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @yyc12345 - I've reviewed your changes - here's some feedback:

  • Consider relocating linguist_file.rs to a more specific module (e.g., under subcmd or a new utils module) if its functionality isn't broadly used across the library.
  • The new comment regarding Windows EOL issues in tests raises a question about intended platform support; please clarify if this limitation is acceptable for the project.
  • Consider consistently applying the new Rustdoc comment style (mentioned in the PR description) to other structs and enums modified or introduced in this refactor, such as those in cli.rs.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@sourcery-ai
Copy link

sourcery-ai bot commented May 9, 2025

Reviewer's Guide

This pull request refactors the project's structure to align with Rust best practices. Key changes include introducing src/lib.rs for central module management, organizing code into new module directories like src/transifex/ and src/subcmd/, and consolidating CLI logic from main.rs into src/cli.rs (which was renamed from src/cli_args.rs). Additionally, some code comments were updated to Rust's documentation comment syntax.

File-Level Changes

Change Details Files
Adopted Rust-standard project layout using lib.rs and module folders.
  • Introduced src/lib.rs as the crate root for module organization and top-level declarations.
  • Created new module files (src/transifex.rs, src/subcmd.rs) and corresponding directories (src/transifex/, src/subcmd/) to group related functionality.
  • Relocated existing source files (e.g., Transifex utilities, subcommand implementations) into these new module directories.
  • Removed module declarations from src/main.rs and updated import paths project-wide to reflect the new structure.
  • Renamed transifex_yaml_file.rs to yaml_file.rs during its move to the src/transifex/ module.
src/main.rs
src/lib.rs
src/transifex.rs
src/subcmd.rs
src/tx_config_file.rs
src/transifex/tx_config_file.rs
src/transifex_yaml_file.rs
src/transifex/yaml_file.rs
src/transifex_rest_api.rs
src/transifex/rest_api.rs
src/subcmd_yaml2txconfig.rs
src/subcmd/yaml2txconfig.rs
src/subcmd_statistics.rs
src/subcmd/statistics.rs
src/subcmd_txconfig2yaml.rs
src/subcmd/txconfig2yaml.rs
src/cli.rs
Renamed cli_args module and file to cli for clarity.
  • Renamed the file src/cli_args.rs to src/cli.rs.
  • Updated module declarations in src/lib.rs and import paths (e.g. in src/main.rs) to use the new cli module name.
src/cli_args.rs
src/cli.rs
src/lib.rs
src/main.rs
Centralized CLI execution logic into the cli module, cleaning up main.rs.
  • Moved command argument parsing and execution logic from main.rs into a new execute() function within src/cli.rs.
  • Simplified main.rs to primarily call deepin_translation_utils::cli::execute().
  • Introduced a CliError enum in src/cli.rs for consolidated error handling from CLI operations.
src/main.rs
src/cli.rs
Switched to Rust documentation comment syntax for improved inline documentation.
  • Converted standard code comments to Rust documentation comments (e.g., ///) for selected structs, fields, and functions.
src/transifex/yaml_file.rs
src/transifex/rest_api.rs
src/subcmd/statistics.rs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

- change project layout to make it suit for Rust best practices.
	* add `lib.rs` to manage modules, rather than declare them in `main.rs`.
	* use module folder to manage project.
- rename `cli_args` to `cli` to make it correspond with its meaning (not only cli arguments, but also all things involving cli).
- move cli executor into `cli` module to make `main.rs` be clean.
- use Rust document syntax to make comments for struct and fields, instead of normal comments.
- fix an unittest which fail on Windows due to EOL issue (CRLF/LF error).
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BLumia, yyc12345

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@BLumia BLumia merged commit 9c2f61b into linuxdeepin:master May 9, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants