Initial commit of the common trick header dev branch - #67
Conversation
|
This is looking pretty good, just a few more edge cases we'll want to fix. Some general script comments:
The purpose section is placed within a second set of parenthesis but it should just stay at one. So I'm seeing the script convert to I'm also seeing the script choke on Trick headers that use a cascading '*', like the following: /*
* PURPOSE: (test)
*
* LIBRARY DEPENDENCY:
* (
* (../src/test.cc)
* )
* /In cases like that, it actually removes everything except the purpose field in the formatted output. This may end up being a nightmare to fix so just let me know if it's feasible to handle this case or not. Realistically, headers formatted this way will already fail our formatting check so the script does its main job, and just from looking around randomly I don't believe this is a common pattern in the repo anyways. For long lines, let's add one more indent when wrapping text just for visual clarity. So for the following header: /*
PURPOSE: (Test)
LIBRARY_DEPENDENCY:
(
(../src/test.cc)
)
PROGRAMMERS:
(
((Nino Tarantino) (CACI) (July 2026) (This is a very long comment that should get wrapped at 80 characters.))
)
*/The programmers section ends up like But I think it would look clearer if the line break was indented to visually separate a continued line from a new entry. Especially if there ends up being multiple entries: |
ninotarantino
left a comment
There was a problem hiding this comment.
Should've left that previous comment as part of the official GitHub review, whoops.
- last list of command line args will be the list of *.hh or *.cc files to be changed - file renamed to apply_cml_common_trick_header.py - script only warns for no PYTHON_MODULE or no cml/cml.* modules present for *.hh files - added ICG: directive - removed nested parenthesis for PURPOSE and ICG directories - script can handle the " /* ***... */ " C/C++ style comments for Trick headers - added extra indentation for lines that exceed the character limit Refs #40
Refs #46
ninotarantino
left a comment
There was a problem hiding this comment.
Just a couple minor changes to the script itself and then I say this is ready to merge. Go ahead and update the initial comment in the description with a brief overview of the changes as well. After those updates are pushed I'll approve this.
| exit_code_dict = {-1 : "error: too many characters in line", | ||
| -2 : "error: invalid indentation", | ||
| -3 : "warning: invalid python module", | ||
| -4 : "warning: no python module found", | ||
| -5 : "error: inline parenthesis"} |
There was a problem hiding this comment.
Can we use an enum or some sort of named variable here? It would also make some spots further down in the code easier to read/maintain. Then instead of return -1 we'd have something like return EXIT_CODE_LINE_TOO_LONG.
| -4 : "warning: no python module found", | ||
| -5 : "error: inline parenthesis"} | ||
|
|
||
| def check_inline_open_parens(text): |
There was a problem hiding this comment.
General comment for this file, let's add docstrings to each function. Doesn't have to be too fancy but it'll be good for maintenance.
| def check_inline_open_parens(text): | |
| def check_inline_open_parens(text): | |
| """ | |
| Returns true if a source file line contains a valid Trick header field followed | |
| by a colon, such as `PURPOSE:`. | |
| Inputs: | |
| -------- | |
| text : str | |
| A line of text from a source file | |
| """ |
Refs #46