diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/compiler-core/slang-doc-extractor.cpp (renamed from source/slang/slang-doc-extractor.cpp) | 137 | ||||
| -rw-r--r-- | source/compiler-core/slang-doc-extractor.h (renamed from source/slang/slang-doc-extractor.h) | 64 | ||||
| -rw-r--r-- | source/slang/slang-ast-print.h | 2 | ||||
| -rw-r--r-- | source/slang/slang-doc-ast.cpp | 139 | ||||
| -rw-r--r-- | source/slang/slang-doc-ast.h | 82 | ||||
| -rw-r--r-- | source/slang/slang-doc-markdown-writer.cpp | 22 | ||||
| -rw-r--r-- | source/slang/slang-doc-markdown-writer.h | 25 | ||||
| -rw-r--r-- | source/slang/slang.cpp | 10 |
8 files changed, 261 insertions, 220 deletions
diff --git a/source/slang/slang-doc-extractor.cpp b/source/compiler-core/slang-doc-extractor.cpp index 0677e2af4..d26ed01d1 100644 --- a/source/slang/slang-doc-extractor.cpp +++ b/source/compiler-core/slang-doc-extractor.cpp @@ -1,11 +1,8 @@ -// slang-doc.cpp +// slang-doc-extractor.cpp #include "slang-doc-extractor.h" #include "../core/slang-string-util.h" -#include "slang-ast-builder.h" -#include "slang-ast-print.h" - namespace Slang { /* TODO(JS): @@ -584,38 +581,6 @@ SlangResult DocMarkupExtractor::_findMarkup(const FindInfo& info, const Location return SLANG_OK; } -/* static */DocMarkupExtractor::SearchStyle DocMarkupExtractor::getSearchStyle(Decl* decl) -{ - if (auto enumCaseDecl = as<EnumCaseDecl>(decl)) - { - return SearchStyle::EnumCase; - } - if (auto paramDecl = as<ParamDecl>(decl)) - { - return SearchStyle::Param; - } - else if (auto callableDecl = as<CallableDecl>(decl)) - { - return SearchStyle::Function; - } - else if (as<VarDecl>(decl) || as<TypeDefDecl>(decl) || as<AssocTypeDecl>(decl)) - { - return SearchStyle::Variable; - } - else if (auto genericDecl = as<GenericDecl>(decl)) - { - return getSearchStyle(genericDecl->inner); - } - else if (as<GenericTypeParamDecl>(decl) || as<GenericValueParamDecl>(decl)) - { - return SearchStyle::GenericParam; - } - else - { - // If can't determine just allow before - return SearchStyle::Before; - } -} SlangResult DocMarkupExtractor::_findMarkup(const FindInfo& info, SearchStyle searchStyle, FoundMarkup& out) { @@ -657,7 +622,6 @@ SlangResult DocMarkupExtractor::_findMarkup(const FindInfo& info, SearchStyle se } } - static void _calcLineVisibility(SourceView* sourceView, const TokenList& toks, List<MarkupVisibility>& outLineVisibility) { SourceFile* sourceFile = sourceView->getSourceFile(); @@ -720,7 +684,6 @@ static void _calcLineVisibility(SourceView* sourceView, const TokenList& toks, L } } - SlangResult DocMarkupExtractor::extract(const SearchItemInput* inputs, Index inputCount, SourceManager* sourceManager, DiagnosticSink* sink, List<SourceView*>& outViews, List<SearchItemOutput>& out) { struct Entry @@ -758,6 +721,11 @@ SlangResult DocMarkupExtractor::extract(const SearchItemInput* inputs, Index inp for (auto& entry : entries) { + if (entry.searchStyle == SearchStyle::None) + { + continue; + } + const SourceLoc loc = SourceLoc::fromRaw(entry.locOrOffset); if (sourceView == nullptr || !sourceView->getRange().contains(loc)) @@ -893,97 +861,4 @@ SlangResult DocMarkupExtractor::extract(const SearchItemInput* inputs, Index inp return SLANG_OK; } -static void _addDeclRec(Decl* decl, List<Decl*>& outDecls) -{ - if (decl == nullptr) - { - return; - } - - // If we don't have a loc, we have no way of locating documentation. - if (decl->loc.isValid() || decl->nameAndLoc.loc.isValid()) - { - outDecls.add(decl); - } - else - { - SLANG_ASSERT(!"Decl without a location!"); - } - - if (GenericDecl* genericDecl = as<GenericDecl>(decl)) - { - _addDeclRec(genericDecl->inner, outDecls); - } - - if (ContainerDecl* containerDecl = as<ContainerDecl>(decl)) - { - // Add the container - which could be a class, struct, enum, namespace, extension, generic etc. - // Now add what the container contains - for (Decl* childDecl : containerDecl->members) - { - _addDeclRec(childDecl, outDecls); - } - } -} - -/* static */void DocMarkupExtractor::findDecls(ModuleDecl* moduleDecl, List<Decl*>& outDecls) -{ - for (Decl* decl : moduleDecl->members) - { - _addDeclRec(decl, outDecls); - } -} - -SlangResult DocMarkupExtractor::extract(ModuleDecl* moduleDecl, SourceManager* sourceManager, DiagnosticSink* sink, DocMarkup* outDoc) -{ - List<Decl*> decls; - findDecls(moduleDecl, decls); - - const Index declsCount = decls.getCount(); - - List<SearchItemInput> inputItems; - List<SearchItemOutput> outItems; - - { - inputItems.setCount(declsCount); - - for (Index i = 0; i < declsCount; ++i) - { - Decl* decl = decls[i]; - auto& item = inputItems[i]; - - item.sourceLoc = decl->loc.isValid() ? decl->loc : decl->nameAndLoc.loc; - // Has to be valid to be lookupable - SLANG_ASSERT(item.sourceLoc.isValid()); - - item.searchStyle = getSearchStyle(decl); - } - - DocMarkupExtractor extractor; - - List<SourceView*> views; - SLANG_RETURN_ON_FAIL(extractor.extract(inputItems.getBuffer(), declsCount, sourceManager, sink, views, outItems)); - } - - // Set back - for (Index i = 0; i < declsCount; ++i) - { - const auto& outputItem = outItems[i]; - const auto& inputItem = inputItems[outputItem.inputIndex]; - - // If we don't know how to search add to the output - if (inputItem.searchStyle != SearchStyle::None) - { - Decl* decl = decls[outputItem.inputIndex]; - - // Add to the documentation - DocMarkup::Entry& docEntry = outDoc->addEntry(decl); - docEntry.m_markup = outputItem.text; - docEntry.m_visibility = outputItem.visibilty; - } - } - - return SLANG_OK; -} - } // namespace Slang diff --git a/source/slang/slang-doc-extractor.h b/source/compiler-core/slang-doc-extractor.h index 7a33b390a..5b4c67782 100644 --- a/source/slang/slang-doc-extractor.h +++ b/source/compiler-core/slang-doc-extractor.h @@ -3,7 +3,9 @@ #define SLANG_DOC_EXTRACTOR_H #include "../core/slang-basic.h" -#include "slang-ast-all.h" + +#include "slang-source-loc.h" +#include "slang-lexer.h" namespace Slang { @@ -14,55 +16,6 @@ enum class MarkupVisibility : uint8_t Hidden, ///< Not generally available }; -/* Holds the documentation markup that is associated with each node (typically a decl) from a module */ -class DocMarkup : public RefObject -{ -public: - struct Entry - { - NodeBase* m_node; ///< The node this documentation is associated with - String m_markup; ///< The raw contents of of markup associated with the decoration - MarkupVisibility m_visibility = MarkupVisibility::Public; ///< How visible this decl is - }; - - /// Adds an entry, returns the reference to pre-existing node if there is one - Entry& addEntry(NodeBase* base); - /// Gets an entry for a node. Returns nullptr if there is no markup. - Entry* getEntry(NodeBase* base); - - /// Get list of all of the entries in source order - const List<Entry>& getEntries() const { return m_entries; } - -protected: - - /// Map from AST nodes to documentation entries - Dictionary<NodeBase*, Index> m_entryMap; - /// All of the documentation entries in source order - List<Entry> m_entries; -}; - -// --------------------------------------------------------------------------- -SLANG_INLINE DocMarkup::Entry& DocMarkup::addEntry(NodeBase* base) -{ - const Index count = m_entries.getCount(); - const Index index = m_entryMap.GetOrAddValue(base, count); - - if (index == count) - { - Entry entry; - entry.m_node = base; - m_entries.add(entry); - } - return m_entries[index]; -} - -// --------------------------------------------------------------------------- -SLANG_INLINE DocMarkup::Entry* DocMarkup::getEntry(NodeBase* base) -{ - Index* indexPtr = m_entryMap.TryGetValue(base); - return (indexPtr) ? &m_entries[*indexPtr] : nullptr; -} - /* Extracts 'markup' from comments in Slang source core. The comments are extracted and associated in declarations. The association is held in DocMarkup type. The comment style follows the doxygen style */ class DocMarkupExtractor @@ -168,22 +121,13 @@ public: Index lineIndex; ///< The line number for the decl }; - /// Extracts documentation from the nodes held in the module using the source manager. Found documentation is placed - /// in outMarkup - static SlangResult extract(ModuleDecl* moduleDecl, SourceManager* sourceManager, DiagnosticSink* sink, DocMarkup* outMarkup); - + /// Extracts 'markup' doc information for the specified input items /// The output is placed in out - with the items now in the source order *not* the order of the input items /// The inputIndex on the output holds the input item index /// The outViews holds the views specified in viewIndex in the output, which may be useful for determining where the documentation was placed in source SlangResult extract(const SearchItemInput* inputItems, Index inputCount, SourceManager* sourceManager, DiagnosticSink* sink, List<SourceView*>& outViews, List<SearchItemOutput>& out); - /// Given a module finds all the decls, and places in outDecls - static void findDecls(ModuleDecl* moduleDecl, List<Decl*>& outDecls); - - /// Given a decl determines the search style that is appropriate. Returns None if can't determine a suitable style - static SearchStyle getSearchStyle(Decl* decl); - static MarkupFlags getFlags(MarkupType type); static MarkupType findMarkupType(const Token& tok); static UnownedStringSlice removeStart(MarkupType type, const UnownedStringSlice& comment); diff --git a/source/slang/slang-ast-print.h b/source/slang/slang-ast-print.h index 1c4c20e28..15ca58acf 100644 --- a/source/slang/slang-ast-print.h +++ b/source/slang/slang-ast-print.h @@ -139,7 +139,7 @@ public: UnownedStringSlice getPartSlice(const Part& part) const { return getPart(getSlice(), part); } /// Gets the specified part type - static UnownedStringSlice getPart(const UnownedStringSlice& slice, const Part& part) { return UnownedStringSlice(slice.begin() + part.start, slice.begin() + part.end); } + static UnownedStringSlice getPart(const UnownedStringSlice& slice, const Part& part) { return (part.type != Part::Type::None) ? UnownedStringSlice(slice.begin() + part.start, slice.begin() + part.end) : UnownedStringSlice(); } static UnownedStringSlice getPart(Part::Type partType, const UnownedStringSlice& slice, const List<Part>& parts); static void appendDeclName(Decl* decl, StringBuilder& out); diff --git a/source/slang/slang-doc-ast.cpp b/source/slang/slang-doc-ast.cpp new file mode 100644 index 000000000..8301b1a63 --- /dev/null +++ b/source/slang/slang-doc-ast.cpp @@ -0,0 +1,139 @@ +// slang-doc-ast.cpp +#include "slang-doc-ast.h" + +#include "../core/slang-string-util.h" + +//#include "slang-ast-builder.h" +//#include "slang-ast-print.h" + +namespace Slang { + +/* static */DocMarkupExtractor::SearchStyle ASTMarkupUtil::getSearchStyle(Decl* decl) +{ + typedef Extractor::SearchStyle SearchStyle; + + if (auto enumCaseDecl = as<EnumCaseDecl>(decl)) + { + return SearchStyle::EnumCase; + } + if (auto paramDecl = as<ParamDecl>(decl)) + { + return SearchStyle::Param; + } + else if (auto callableDecl = as<CallableDecl>(decl)) + { + return SearchStyle::Function; + } + else if (as<VarDecl>(decl) || as<TypeDefDecl>(decl) || as<AssocTypeDecl>(decl)) + { + return SearchStyle::Variable; + } + else if (auto genericDecl = as<GenericDecl>(decl)) + { + return getSearchStyle(genericDecl->inner); + } + else if (as<GenericTypeParamDecl>(decl) || as<GenericValueParamDecl>(decl)) + { + return SearchStyle::GenericParam; + } + else + { + // If can't determine just allow before + return SearchStyle::Before; + } +} + +static void _addDeclRec(Decl* decl, List<Decl*>& outDecls) +{ + if (decl == nullptr) + { + return; + } + + // If we don't have a loc, we have no way of locating documentation. + if (decl->loc.isValid() || decl->nameAndLoc.loc.isValid()) + { + outDecls.add(decl); + } + else + { + SLANG_ASSERT(!"Decl without a location!"); + } + + if (GenericDecl* genericDecl = as<GenericDecl>(decl)) + { + _addDeclRec(genericDecl->inner, outDecls); + } + + if (ContainerDecl* containerDecl = as<ContainerDecl>(decl)) + { + // Add the container - which could be a class, struct, enum, namespace, extension, generic etc. + // Now add what the container contains + for (Decl* childDecl : containerDecl->members) + { + _addDeclRec(childDecl, outDecls); + } + } +} + +/* static */void ASTMarkupUtil::findDecls(ModuleDecl* moduleDecl, List<Decl*>& outDecls) +{ + for (Decl* decl : moduleDecl->members) + { + _addDeclRec(decl, outDecls); + } +} + +SlangResult ASTMarkupUtil::extract(ModuleDecl* moduleDecl, SourceManager* sourceManager, DiagnosticSink* sink, ASTMarkup* outDoc) +{ + List<Decl*> decls; + findDecls(moduleDecl, decls); + + const Index declsCount = decls.getCount(); + + List<Extractor::SearchItemInput> inputItems; + List<Extractor::SearchItemOutput> outItems; + + { + inputItems.setCount(declsCount); + + for (Index i = 0; i < declsCount; ++i) + { + Decl* decl = decls[i]; + auto& item = inputItems[i]; + + item.sourceLoc = decl->loc.isValid() ? decl->loc : decl->nameAndLoc.loc; + // Has to be valid to be lookupable + SLANG_ASSERT(item.sourceLoc.isValid()); + + item.searchStyle = getSearchStyle(decl); + } + + DocMarkupExtractor extractor; + + List<SourceView*> views; + SLANG_RETURN_ON_FAIL(extractor.extract(inputItems.getBuffer(), declsCount, sourceManager, sink, views, outItems)); + } + + // Set back + for (Index i = 0; i < declsCount; ++i) + { + const auto& outputItem = outItems[i]; + const auto& inputItem = inputItems[outputItem.inputIndex]; + + // If we don't know how to search add to the output + if (inputItem.searchStyle != Extractor::SearchStyle::None) + { + Decl* decl = decls[outputItem.inputIndex]; + + // Add to the documentation + ASTMarkup::Entry& docEntry = outDoc->addEntry(decl); + docEntry.m_markup = outputItem.text; + docEntry.m_visibility = outputItem.visibilty; + } + } + + return SLANG_OK; +} + +} // namespace Slang diff --git a/source/slang/slang-doc-ast.h b/source/slang/slang-doc-ast.h new file mode 100644 index 000000000..c5291a31a --- /dev/null +++ b/source/slang/slang-doc-ast.h @@ -0,0 +1,82 @@ +// slang-doc-ast.h +#ifndef SLANG_DOC_AST_H +#define SLANG_DOC_AST_H + +#include "../core/slang-basic.h" + +#include "../compiler-core/slang-doc-extractor.h" + +#include "slang-ast-all.h" + +namespace Slang { + +/* Holds the documentation markup that is associated with each node (typically a decl) from a module */ +class ASTMarkup : public RefObject +{ +public: + struct Entry + { + NodeBase* m_node; ///< The node this documentation is associated with + String m_markup; ///< The raw contents of of markup associated with the decoration + MarkupVisibility m_visibility = MarkupVisibility::Public; ///< How visible this decl is + }; + + /// Adds an entry, returns the reference to pre-existing node if there is one + Entry& addEntry(NodeBase* base); + /// Gets an entry for a node. Returns nullptr if there is no markup. + Entry* getEntry(NodeBase* base); + + /// Get list of all of the entries in source order + const List<Entry>& getEntries() const { return m_entries; } + +protected: + + /// Map from AST nodes to documentation entries + Dictionary<NodeBase*, Index> m_entryMap; + /// All of the documentation entries in source order + List<Entry> m_entries; +}; + +// --------------------------------------------------------------------------- +SLANG_INLINE ASTMarkup::Entry& ASTMarkup::addEntry(NodeBase* base) +{ + const Index count = m_entries.getCount(); + const Index index = m_entryMap.GetOrAddValue(base, count); + + if (index == count) + { + Entry entry; + entry.m_node = base; + m_entries.add(entry); + } + return m_entries[index]; +} + +// --------------------------------------------------------------------------- +SLANG_INLINE ASTMarkup::Entry* ASTMarkup::getEntry(NodeBase* base) +{ + Index* indexPtr = m_entryMap.TryGetValue(base); + return (indexPtr) ? &m_entries[*indexPtr] : nullptr; +} + +/* Extracts documentation markup from source. +The comments are extracted and associated in declarations. The association +is held in DocMarkup type. The comment style follows the doxygen style */ +struct ASTMarkupUtil +{ + typedef DocMarkupExtractor Extractor; + + /// Given a module finds all the decls, and places in outDecls + static void findDecls(ModuleDecl* moduleDecl, List<Decl*>& outDecls); + + /// Given a decl determines the search style that is appropriate. Returns None if can't determine a suitable style + static Extractor::SearchStyle getSearchStyle(Decl* decl); + + /// Extracts documentation from the nodes held in the module using the source manager. Found documentation is placed + /// in outMarkup + static SlangResult extract(ModuleDecl* moduleDecl, SourceManager* sourceManager, DiagnosticSink* sink, ASTMarkup* outMarkup); +}; + +} // namespace Slang + +#endif diff --git a/source/slang/slang-doc-markdown-writer.cpp b/source/slang/slang-doc-markdown-writer.cpp index 2a1226bb7..4d8afd763 100644 --- a/source/slang/slang-doc-markdown-writer.cpp +++ b/source/slang/slang-doc-markdown-writer.cpp @@ -128,7 +128,7 @@ String DocMarkdownWriter::_getName(InheritanceDecl* decl) return buf.ProduceString(); } -DocMarkdownWriter::NameAndText DocMarkdownWriter::_getNameAndText(DocMarkup::Entry* entry, Decl* decl) +DocMarkdownWriter::NameAndText DocMarkdownWriter::_getNameAndText(ASTMarkup::Entry* entry, Decl* decl) { NameAndText nameAndText; @@ -146,7 +146,7 @@ DocMarkdownWriter::NameAndText DocMarkdownWriter::_getNameAndText(DocMarkup::Ent DocMarkdownWriter::NameAndText DocMarkdownWriter::_getNameAndText(Decl* decl) { - DocMarkup::Entry* entry = m_markup->getEntry(decl); + ASTMarkup::Entry* entry = m_markup->getEntry(decl); return _getNameAndText(entry, decl); } @@ -242,7 +242,7 @@ void DocMarkdownWriter::_appendCommaList(const List<String>& strings, char wrapC } } -void DocMarkdownWriter::writeVar(const DocMarkup::Entry& entry, VarDecl* varDecl) +void DocMarkdownWriter::writeVar(const ASTMarkup::Entry& entry, VarDecl* varDecl) { writePreamble(entry); auto& out = m_builder; @@ -680,7 +680,7 @@ static bool _isFirstOverridden(Decl* decl) return false; } -void DocMarkdownWriter::writeCallableOverridable(const DocMarkup::Entry& entry, CallableDecl* callableDecl) +void DocMarkdownWriter::writeCallableOverridable(const ASTMarkup::Entry& entry, CallableDecl* callableDecl) { auto& out = m_builder; @@ -843,7 +843,7 @@ void DocMarkdownWriter::writeCallableOverridable(const DocMarkup::Entry& entry, } } -void DocMarkdownWriter::writeEnum(const DocMarkup::Entry& entry, EnumDecl* enumDecl) +void DocMarkdownWriter::writeEnum(const ASTMarkup::Entry& entry, EnumDecl* enumDecl) { writePreamble(entry); @@ -963,7 +963,7 @@ void DocMarkdownWriter::_appendAggTypeName(AggTypeDeclBase* aggTypeDecl) } } -void DocMarkdownWriter::writeAggType(const DocMarkup::Entry& entry, AggTypeDeclBase* aggTypeDecl) +void DocMarkdownWriter::writeAggType(const ASTMarkup::Entry& entry, AggTypeDeclBase* aggTypeDecl) { writePreamble(entry); @@ -1005,7 +1005,7 @@ void DocMarkdownWriter::writeAggType(const DocMarkup::Entry& entry, AggTypeDeclB out << "* _" << assocTypeDecl->getName()->text << "_ "; // Look up markup - DocMarkup::Entry* assocTypeDeclEntry = m_markup->getEntry(assocTypeDecl); + ASTMarkup::Entry* assocTypeDeclEntry = m_markup->getEntry(assocTypeDecl); if (assocTypeDeclEntry) { _appendAsSingleLine(assocTypeDeclEntry->m_markup.getUnownedSlice(), out); @@ -1086,7 +1086,7 @@ void DocMarkdownWriter::writeAggType(const DocMarkup::Entry& entry, AggTypeDeclB } } -void DocMarkdownWriter::writePreamble(const DocMarkup::Entry& entry) +void DocMarkdownWriter::writePreamble(const ASTMarkup::Entry& entry) { SLANG_UNUSED(entry); auto& out = m_builder; @@ -1097,7 +1097,7 @@ void DocMarkdownWriter::writePreamble(const DocMarkup::Entry& entry) out << toSlice("\n"); } -void DocMarkdownWriter::writeDescription(const DocMarkup::Entry& entry) +void DocMarkdownWriter::writeDescription(const ASTMarkup::Entry& entry) { auto& out = m_builder; @@ -1117,7 +1117,7 @@ void DocMarkdownWriter::writeDescription(const DocMarkup::Entry& entry) } } -void DocMarkdownWriter::writeDecl(const DocMarkup::Entry& entry, Decl* decl) +void DocMarkdownWriter::writeDecl(const ASTMarkup::Entry& entry, Decl* decl) { // Skip these they will be output as part of their respective 'containers' if (as<ParamDecl>(decl) || as<EnumCaseDecl>(decl) || as<AssocTypeDecl>(decl) || as<InheritanceDecl>(decl)) @@ -1161,7 +1161,7 @@ bool DocMarkdownWriter::isVisible(const Name* name) return name == nullptr || !name->text.startsWith(toSlice("__")); } -bool DocMarkdownWriter::isVisible(const DocMarkup::Entry& entry) +bool DocMarkdownWriter::isVisible(const ASTMarkup::Entry& entry) { // For now if it's not public it's not visible if (entry.m_visibility != MarkupVisibility::Public) diff --git a/source/slang/slang-doc-markdown-writer.h b/source/slang/slang-doc-markdown-writer.h index 7a6c0a7e0..ff4c50759 100644 --- a/source/slang/slang-doc-markdown-writer.h +++ b/source/slang/slang-doc-markdown-writer.h @@ -2,7 +2,8 @@ #ifndef SLANG_DOC_MARKDOWN_WRITER_H #define SLANG_DOC_MARKDOWN_WRITER_H -#include "slang-doc-extractor.h" +#include "slang-doc-ast.h" + #include "slang-ast-print.h" #include "slang-compiler.h" @@ -50,19 +51,19 @@ struct DocMarkdownWriter void writeAll(); /// This will write information about *all* of the overridden versions of a function/method - void writeCallableOverridable(const DocMarkup::Entry& entry, CallableDecl* callable); + void writeCallableOverridable(const ASTMarkup::Entry& entry, CallableDecl* callable); - void writeEnum(const DocMarkup::Entry& entry, EnumDecl* enumDecl); - void writeAggType(const DocMarkup::Entry& entry, AggTypeDeclBase* aggTypeDecl); - void writeDecl(const DocMarkup::Entry& entry, Decl* decl); - void writeVar(const DocMarkup::Entry& entry, VarDecl* varDecl); + void writeEnum(const ASTMarkup::Entry& entry, EnumDecl* enumDecl); + void writeAggType(const ASTMarkup::Entry& entry, AggTypeDeclBase* aggTypeDecl); + void writeDecl(const ASTMarkup::Entry& entry, Decl* decl); + void writeVar(const ASTMarkup::Entry& entry, VarDecl* varDecl); - void writePreamble(const DocMarkup::Entry& entry); - void writeDescription(const DocMarkup::Entry& entry); + void writePreamble(const ASTMarkup::Entry& entry); + void writeDescription(const ASTMarkup::Entry& entry); void writeSignature(CallableDecl* callableDecl); - bool isVisible(const DocMarkup::Entry& entry); + bool isVisible(const ASTMarkup::Entry& entry); bool isVisible(Decl* decl); bool isVisible(const Name* name); @@ -70,7 +71,7 @@ struct DocMarkdownWriter const StringBuilder& getOutput() const { return m_builder; } /// Ctor. - DocMarkdownWriter(DocMarkup* markup, ASTBuilder* astBuilder) : + DocMarkdownWriter(ASTMarkup* markup, ASTBuilder* astBuilder) : m_markup(markup), m_astBuilder(astBuilder) { @@ -92,7 +93,7 @@ struct DocMarkdownWriter String _getName(Decl* decl); String _getName(InheritanceDecl* decl); - NameAndText _getNameAndText(DocMarkup::Entry* entry, Decl* decl); + NameAndText _getNameAndText(ASTMarkup::Entry* entry, Decl* decl); NameAndText _getNameAndText(Decl* decl); template <typename T> @@ -134,7 +135,7 @@ struct DocMarkdownWriter void _appendAggTypeName(AggTypeDeclBase* aggTypeDecl); - DocMarkup* m_markup; + ASTMarkup* m_markup; ASTBuilder* m_astBuilder; StringBuilder m_builder; }; diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 67908841f..e0b11604c 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -31,7 +31,7 @@ #include "slang-serialize-ir.h" #include "slang-serialize-container.h" -#include "slang-doc-extractor.h" +#include "slang-doc-ast.h" #include "slang-doc-markdown-writer.h" #include "slang-check-impl.h" @@ -300,8 +300,8 @@ SlangResult Session::compileStdLib(slang::CompileStdLibFlags compileFlags) // For all the modules add their doc output to docStrings for (Module* stdlibModule : stdlibModules) { - RefPtr<DocMarkup> markup(new DocMarkup); - DocMarkupExtractor::extract(stdlibModule->getModuleDecl(), sourceManager, &sink, markup); + RefPtr<ASTMarkup> markup(new ASTMarkup); + ASTMarkupUtil::extract(stdlibModule->getModuleDecl(), sourceManager, &sink, markup); DocMarkdownWriter writer(markup, astBuilder); writer.writeAll(); @@ -2150,8 +2150,8 @@ SlangResult FrontEndCompileRequest::executeActionsInner() { for (TranslationUnitRequest* translationUnit : translationUnits) { - RefPtr<DocMarkup> markup(new DocMarkup); - DocMarkupExtractor::extract(translationUnit->getModuleDecl(), getSourceManager(), getSink(), markup); + RefPtr<ASTMarkup> markup(new ASTMarkup); + ASTMarkupUtil::extract(translationUnit->getModuleDecl(), getSourceManager(), getSink(), markup); // Convert to markdown DocMarkdownWriter markdownWriter(markup, astBuilder); |
