Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add devtool text optimizer #4189

Closed
wants to merge 22 commits into from

Conversation

EthanYuan
Copy link
Collaborator

@EthanYuan EthanYuan commented Oct 12, 2023

What problem does this PR solve?

Problem Summary:

CKB, being an executable program, produces a wide array of output messages during its runtime. These messages include console logs, error notifications, and text displayed within subcommands. These texts are authored by different developers at different stages of the development process, resulting in variations in language style and the possibility of syntax errors.

Optimizing these messages by manually going through the code is very difficult. This is because the code is very large, and these text messages are spread all over it.

Hence, what we require is a tool that can efficiently gather these texts and, after optimization, precisely reintegrate them into the source code.

What is changed and how it works?

We conducted research on solutions based on "regex" and "i18n". For the current PR, we have chosen an approach based on source code analysis using dtolnay/syn. With this approach, we will gain the following advantages:

  • Non-intrusive: The solution does not intrude into the code.
  • Improved maintainability: Compared to “regex“, this method offers better maintainability.
  • Versatile feature extraction: "syn" can identify macros, function calls, attribute macros, and more, expanding the range of extractable features and enhancing accuracy.
  • Leveraging other "syn" features, such as framework traversal.

The extracted text will be saved in a YAML file, and here is an overview:

# Number of TextInfo items: 80

- original: 'Config Error: {err:?}'
  editable: 'Config Error: {err:?}'
  metadata:
    category: StdError
    file: ../../ckb-bin/src/setup_guard.rs
    code_line_link:
    - https://github.com/nervosnetwork/ckb/tree/58419a7a8ec7724f57ff112ec86efb6e2a873ed0/ckb-bin/src/setup_guard.rs#L64
    - https://github.com/nervosnetwork/ckb/tree/58419a7a8ec7724f57ff112ec86efb6e2a873ed0/ckb-bin/src/setup_guard.rs#L92
- original: 'Export error: {err:?}'
  editable: 'Export error: {err:?}'
  metadata:
    category: StdError
    file: ../../ckb-bin/src/subcommand/export.rs
    code_line_link:
    - https://github.com/nervosnetwork/ckb/tree/58419a7a8ec7724f57ff112ec86efb6e2a873ed0/ckb-bin/src/subcommand/export.rs#L16

Check List

Tests

  • Manual test

Release note

Title Only: Include only the PR title in the release note.

@EthanYuan EthanYuan force-pushed the tool-text-optimizer branch from 6c76d10 to 5860cd2 Compare October 30, 2023 00:47
@EthanYuan EthanYuan self-assigned this Nov 30, 2023
Copy link

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the stale To be closed due to a lack of activity label Jul 28, 2024
Copy link

github-actions bot commented Aug 8, 2024

This PR was closed because it has been stalled for 10 days with no activity.

@github-actions github-actions bot closed this Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale To be closed due to a lack of activity
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant