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
chpldoc/next - now with queries #18956
Conversation
Squash of progress on chpldoc/next overhaul to use queries. That was an easy step. Adds an initial implementation of actually converting the AST into the appropriate RST format. This uses the visitor and traverse pattern. Added a hack environment variable to sub_test.py so that CHPL_CHPLDOC_NEXT can be specified to use it instead of today's chpldoc. This was because PATH get's messed with by fixpath.py Note this "requires" C++17 only as a convenience step in prototyping to get the fileystem functionality. Today we only pass 1 test case. Many are whitespace only which is a good sign, just ran out of time to address them. Signed-off-by: Andrew Consroe <andrew.consroe@hpe.com>
/* | ||
To test this today, you can force sub_test to use this version by doing: | ||
> CHPL_CHPLDOC_NEXT=$(find $(pwd) -name chpldoc -type f) ./util/test/start_test.py test/chpldoc/enum.doc.chpl | ||
You'll want to make sure that the find command finds a single chpldoc executable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative would be to adjust compiler/main/driver
to run this alternative chpldoc implementation.
I think you are saying there are whitespace differences? Which is the 1 test that passes? |
Yes whitespace only differences is what I meant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would it take to only use C++14?
Also this version doesn't implement parts of chpldoc with queries the way I was expecting. It does use a visitor, which is good. I was expecting it to define a one or more queries, e.g. a query (with QUERY_BEGIN) for going from a uAST node for a module or function to a string containing the .rst snippet produced by chpldoc. If there is a reason that you don't want to do that, we should discuss.
return lines[0]; | ||
} | ||
|
||
static const char* kindToRstString(bool isMethod, Function::Kind kind) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe name it FunctionKindToRstString ?
" /* comment 3 */\n" | ||
"}\n" | ||
"/* comment 4 */"; | ||
static const char* kindToString(Function::Visibility kind) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe name it visibilityToString ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the overload is appropriate here
int main(int argc, char **argv) { | ||
Context context; | ||
Context *ctx = &context; | ||
static const char* kindToString(Function::Kind kind) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functionKindToString?
|
||
auto parser = Parser::build(ctx); | ||
Parser *p = parser.get(); | ||
static const char* kindToString(Function::ReturnIntent kind) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
returnIntentToString ?
|
||
auto parseResult = argc == 2 ? parser->parseFile(argv[1]) | ||
: parser->parseString("test1a.chpl", testString); | ||
static const char* kindToString(Formal::Intent kind) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intentToString ?
return ""; | ||
} | ||
|
||
static const char* kindToString(Variable::Kind kind) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variableKindToString?
return ""; | ||
} | ||
|
||
static const char* kindToString(New::Management kind) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newManagementToString?
struct PrettyPrintVisitor { | ||
std::ostream& os_; | ||
|
||
template<typename It> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a comment about what this method is for
Removing the call to std::filesystem::create_directories Heard on the queries part. Seems like the biggest obstacle is knowing what your last comment is. I know we maintain the parent mapping so it should be possible to check your previous sibling but maybe there's a nicer way I'm not thinking of? |
This comment was marked as outdated.
This comment was marked as outdated.
This extends the previous work of adding queries to next/chpldoc by converting the one-shot visitor approach with a qury rstDoc to compute the docs for a given node. These results form a tree with the goal being that the query framework will re-use subtrees that have not changed. This avoids a small blow-up in eagerly concatenating a tree of strings but the main motivation was to kick the tires more on queries. This now passes a whopping 15 chpldoc tests! 138 Failures still :) Also fixes a small bug in mark-functions.h Signed-off-by: Andrew Consroe <andrew.consroe@hpe.com>
Signed-off-by: Andrew Consroe <andrew.consroe@hpe.com>
I implemented the approach we had discussed yesterday, ready for another pass at your leisure @mppf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the impromevents! I think this is looking good, structurally. Please make yourself a few issues to track future work:
- get more chpldoc tests passing with this
- add regular testing of it, somewhere
- remove the C++17 dependency (or migrate our compiler sources to C++17) since we will need to do that before this code can be used in production
Squash of progress on chpldoc/next overhaul to use queries.
Note this "requires" C++17 only as a convenience step in prototyping to get the fileystem functionality. Future work can remove this.
Adds an temporary env var
CHPL_CHPLDOC_NEXT
so that we can force sub_test to use that binary when doing chpldoc tests.Passes 15 tests in test/chpldoc currently