Skip to content

Generate categorized pub.dev docs libraries#61

Draft
JSUYA wants to merge 1 commit intoflutter-tizen:mainfrom
JSUYA:codex/pubdev-category-docs
Draft

Generate categorized pub.dev docs libraries#61
JSUYA wants to merge 1 commit intoflutter-tizen:mainfrom
JSUYA:codex/pubdev-category-docs

Conversation

@JSUYA
Copy link
Member

@JSUYA JSUYA commented Mar 17, 2026

This method is an example script that generates one dart file each for dartdoc_options.yaml and docs for each version.

scripts/prepare_pubdev_module_docs.sh prepare 6.0
scripts/prepare_pubdev_module_docs.sh prepare 6.5
scripts/prepare_pubdev_module_docs.sh prepare 7.0
...
dart doc --validate-links

@JSUYA JSUYA marked this pull request as draft March 17, 2026 14:00
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new tool for generating categorized pub.dev documentation. The implementation is quite extensive, with a large Dart script handling most of the logic. The script correctly handles file operations and has good error handling with cleanup routines. I've found a few areas for improvement regarding robustness and maintainability. Specifically, the parameter parsing logic has a potential bug with unbalanced brackets, and the argument parser could be improved by using package:args. Also, a regular expression for checking command output is a bit too specific and might fail with future SDK updates. For better long-term maintainability, consider splitting the large prepare_pubdev_module_docs.dart file into smaller, more focused libraries for parsing, code generation, and file management.

Comment on lines +827 to +831
} else if (char == '>') {
if (angleDepth > 0) {
angleDepth--;
}
} else if (char == '(') {

Choose a reason for hiding this comment

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

high

The check if (angleDepth > 0) is incorrect and can lead to misparsing of parameters with unbalanced angle brackets. The depth counter should be allowed to become negative to correctly identify top-level commas for splitting parameters. The same issue exists for parenthesis and square bracket depth checking in this function.

    } else if (char == '>') {
      angleDepth--;
    } else if (char == '(') {

Comment on lines +243 to +279
_Config _parseArgs(List<String> args) {
var command = 'verify';
var version = '6.0';
var keepGenerated = false;

for (var index = 0; index < args.length; index++) {
final arg = args[index];
switch (arg) {
case 'prepare':
case 'verify':
case 'clean':
command = arg;
case '--version':
if (index + 1 >= args.length) {
throw ArgumentError('Missing value for --version');
}
version = args[++index];
case '--keep-generated':
keepGenerated = true;
case '-h':
case '--help':
stdout.writeln(
'Usage: dart run tool/prepare_pubdev_module_docs.dart '
'[prepare|verify|clean] [--version 6.0] [--keep-generated]',
);
exit(0);
default:
throw ArgumentError('Unknown argument: $arg');
}
}

return _Config(
command: command,
version: version,
keepGenerated: keepGenerated,
);
}

Choose a reason for hiding this comment

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

medium

This manual argument parsing logic is simple but can be brittle and hard to maintain. For better maintainability and robustness, consider using the package:args library. It's the standard for parsing command-line arguments in Dart and provides features like automatic help message generation, better error reporting for invalid arguments, and a more declarative API.

Comment on lines +1400 to +1401
final hasOnlyWarnings = RegExp(r'Package has \d+ warning').hasMatch(output) &&
!RegExp(r'Package has .*error', caseSensitive: false).hasMatch(output);

Choose a reason for hiding this comment

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

medium

The regular expression to detect warnings only matches the singular "warning". It will fail if pub publish --dry-run outputs multiple warnings (e.g., "Package has 2 warnings").

  final hasOnlyWarnings = RegExp(r'Package has \d+ warnings?').hasMatch(output) &&
      !RegExp(r'Package has .*error', caseSensitive: false).hasMatch(output);

@JSUYA JSUYA force-pushed the codex/pubdev-category-docs branch from 1b09f8f to 22b7f38 Compare March 18, 2026 01:12
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