diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2021-03-01 15:37:46 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-01 15:37:46 -0500 |
| commit | 837a155b3d33035ee0739858f4ab25c65048ad6c (patch) | |
| tree | 7abc4859a6669c9b8e0bcdaad6eb7b37471679ba /source/slang/slang.cpp | |
| parent | b3501add6c4dda798acf7b84b71b638d8d0b7898 (diff) | |
Doc improvements (#1729)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Split out AST 'printing'.
* Replace listener with List<Section>
* Section -> Part.
* Kind -> Type Flags -> Kind for ASTPrinter::Part
* Improve comments around ASTPrinter.
* toString -> toText on Val derived types. toText appends to a StringBuilder.
* Added toSlice free function.
Added operator<< for Val derived types.
Use << where appropriate in doing toText.
* More work at mark down output.
* Fill in sourceloc for enum case.
Add more sophisticated location determination for EnumCase.
Refactored documentation output into DocMarkdownWriter.
* Improvements for sig output.
Diffstat (limited to 'source/slang/slang.cpp')
| -rw-r--r-- | source/slang/slang.cpp | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index e02715015..21f60c090 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -1639,25 +1639,7 @@ void FrontEndCompileRequest::parseTranslationUnit( } } - if (shouldDocument) - { - RefPtr<DocMarkup> markup(new DocMarkup); - markup->extract(translationUnit->getModuleDecl(), getSourceManager(), getSink()); - - // Extract to a file - const String& path = sourceFile->getPathInfo().foundPath; - if (path.getLength()) - { - String fileName = Path::getFileNameWithoutExt(path); - fileName.append(".md"); - - StringBuilder buf; - DocumentationUtil::writeMarkdown(markup, buf); - - File::writeAllText(fileName, buf); - } - } #if 0 // Test serialization @@ -1816,6 +1798,38 @@ SlangResult FrontEndCompileRequest::executeActionsInner() if (getSink()->getErrorCount() != 0) return SLANG_FAIL; + // After semantic checking is performed we can try and output doc information for this + if (shouldDocument) + { + // Not 100% clear where best to get the ASTBuilder from, but from the linkage shouldn't + // cause any problems with scoping + ASTBuilder* astBuilder = getLinkage()->getASTBuilder(); + + for (TranslationUnitRequest* translationUnit : translationUnits) + { + RefPtr<DocMarkup> markup(new DocMarkup); + + markup->extract(translationUnit->getModuleDecl(), getSourceManager(), getSink()); + + // Hmm.. we can have multiple sourcefiles. So fir now we just pick the first, so as to come up with + // a reasonable name + SourceFile* sourceFile = translationUnit->getSourceFiles()[0]; + + // Extract to a file + const String& path = sourceFile->getPathInfo().foundPath; + if (path.getLength()) + { + String fileName = Path::getFileNameWithoutExt(path); + fileName.append(".md"); + + StringBuilder buf; + DocumentationUtil::writeMarkdown(markup, astBuilder, buf); + + File::writeAllText(fileName, buf); + } + } + } + // Look up all the entry points that are expected, // and use them to populate the `program` member. // |
