summaryrefslogtreecommitdiffstats
path: root/source/slang/slang.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-02-23 12:36:46 -0500
committerGitHub <noreply@github.com>2021-02-23 12:36:46 -0500
commit55a5ccc559b34b8d2eb9c7b7a2d9efbae40619c2 (patch)
tree105e60200bc4f6ac13a1845b448886d777a7398a /source/slang/slang.cpp
parent4bf01b04cb6bf1df8d4fb2ec5eee0a912ec679dc (diff)
Documentation markup extraction (#1724)
* #include an absolute path didn't work - because paths were taken to always be relative. * WIP extracting source documentation. * WIP doc extraction. * More stuff around doc markup extraction. * More WIP around doc extraction. * Fix some indexing issues. * Initial doc extraction working. * Renaming of types in markup extraction process. * Extracting markup content. Removing indenting. Other fixes and improvements around document tools. * WIP support for documentation system. * Remove some commented out sections. * Remove some comments that no longer apply. * Improvements around SourceFile - such that more granularity around line ops. Made some functionality explicitly work without source. Improved Doc types nameing.
Diffstat (limited to 'source/slang/slang.cpp')
-rw-r--r--source/slang/slang.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index 14f30c632..e02715015 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -30,6 +30,8 @@
#include "slang-serialize-ir.h"
#include "slang-serialize-container.h"
+#include "slang-doc.h"
+
#include "slang-check-impl.h"
#include "../../slang-tag-version.h"
@@ -1637,6 +1639,26 @@ 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
{