Skip to content

Commit dee9fdf

Browse files
committed
refactor: modular ASTVisitor
1 parent 3470b10 commit dee9fdf

File tree

89 files changed

+7343
-5087
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+7343
-5087
lines changed

.github/workflows/ci.yml

+45-24
Original file line numberDiff line numberDiff line change
@@ -536,38 +536,59 @@ jobs:
536536
trace-commands: true
537537

538538
- name: Set up llvm-symbolizer
539-
if: ${{ runner.os == 'macOS' }}
539+
if: ${{ runner.os != 'Windows' }}
540540
run: |
541541
set -x
542-
543-
# Step 1: Check if llvm-symbolizer is installed
544-
if ! command -v llvm-symbolizer &> /dev/null; then
545-
echo "llvm-symbolizer is not installed. Installing via Homebrew..."
546-
# Step 2: Install llvm if not installed
547-
if command -v brew &> /dev/null; then
548-
brew install llvm
549-
else
550-
echo "Homebrew is not installed. Please install Homebrew first: https://brew.sh/"
551-
exit 1
552-
fi
553-
fi
554-
555-
# Step 3: Ensure llvm-symbolizer is in your PATH
556-
llvm_bin_path=$(brew --prefix)/opt/llvm/bin
557-
PATH="$PATH:$llvm_bin_path"
558-
LLVM_SYMBOLIZER_PATH=$(which llvm-symbolizer)
559-
if [ -z "$LLVM_SYMBOLIZER_PATH" ]; then
560-
echo "llvm-symbolizer installation failed or it's not in the PATH."
561-
exit 1
542+
543+
if [[ $RUNNER_OS == 'macOS' ]]; then
544+
# Step 1: Check if llvm-symbolizer is installed
545+
if ! command -v llvm-symbolizer &> /dev/null; then
546+
echo "llvm-symbolizer is not installed. Installing via Homebrew..."
547+
# Step 2: Install llvm if not installed
548+
if command -v brew &> /dev/null; then
549+
brew install llvm
550+
else
551+
echo "Homebrew is not installed. Please install Homebrew first: https://brew.sh/"
552+
exit 1
553+
fi
554+
fi
555+
556+
# Step 3: Ensure llvm-symbolizer is in your PATH
557+
llvm_bin_path=$(brew --prefix)/opt/llvm/bin
558+
PATH="$PATH:$llvm_bin_path"
559+
LLVM_SYMBOLIZER_PATH=$(which llvm-symbolizer)
560+
if [ -z "$LLVM_SYMBOLIZER_PATH" ]; then
561+
echo "llvm-symbolizer installation failed or it's not in the PATH."
562+
exit 1
563+
else
564+
echo "llvm-symbolizer found at: $LLVM_SYMBOLIZER_PATH"
565+
fi
566+
elif [[ $RUNNER_OS == 'Linux' ]]; then
567+
# Step 1: Check if llvm-symbolizer is installed
568+
if ! command -v llvm-symbolizer &> /dev/null; then
569+
echo "llvm-symbolizer is not installed. Installing via apt-get..."
570+
apt-get update
571+
apt-get install -y llvm
572+
fi
573+
574+
# Step 2: Ensure llvm-symbolizer is in your PATH
575+
LLVM_SYMBOLIZER_PATH=$(which llvm-symbolizer)
576+
if [ -z "$LLVM_SYMBOLIZER_PATH" ]; then
577+
echo "llvm-symbolizer installation failed or it's not in the PATH."
578+
exit 1
579+
else
580+
echo "llvm-symbolizer found at: $LLVM_SYMBOLIZER_PATH"
581+
fi
562582
else
563-
echo "llvm-symbolizer found at: $LLVM_SYMBOLIZER_PATH"
583+
echo "Unsupported OS: $RUNNER_OS"
584+
exit 1
564585
fi
565-
586+
566587
# Step 4: Export LLVM_SYMBOLIZER_PATH environment variable
567588
export LLVM_SYMBOLIZER_PATH="$LLVM_SYMBOLIZER_PATH"
568589
echo -e "LLVM_SYMBOLIZER_PATH=$LLVM_SYMBOLIZER_PATH" >> $GITHUB_ENV
569590
echo "Environment variable LLVM_SYMBOLIZER_PATH set to: $LLVM_SYMBOLIZER_PATH"
570-
591+
571592
- name: Generate Landing Page
572593
working-directory: docs/website
573594
run: |

docs/modules/ROOT/pages/design-notes.adoc

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ Here are a few constructs MrDocs attempts to understand and document automatical
7878
* Private APIs
7979
* Unspecified Return Types
8080
* Concepts
81-
* Typedef / Aliases
81+
* Typedefs
82+
* Namespace Aliases
8283
* Constants
8384
* Automatic Related Types
8485
* Macros

docs/modules/ROOT/pages/generators.adoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ When the symbol kind is `friend`, the symbol object has the following additional
499499
| The friend type.
500500
|===
501501

502-
When the symbol kind is `alias`, the symbol object has the following additional properties:
502+
When the symbol kind is `namespace-alias`, the symbol object has the following additional properties:
503503

504504
|===
505505
| Property | Type | Description
@@ -527,14 +527,14 @@ When the symbol kind is `using`, the symbol object has the following additional
527527
| The qualifier of the using declaration.
528528
|===
529529

530-
When the symbol kind is `enumerator`, the symbol object has the following additional properties:
530+
When the symbol kind is `enum-constant`, the symbol object has the following additional properties:
531531

532532
|===
533533
| Property | Type | Description
534534

535535
| `initializer`
536536
| `string`
537-
| The initializer of the enumerator.
537+
| The initializer of the enum-constant.
538538
|===
539539

540540
When the symbol kind is `guide`, the symbol object has the following additional properties:

docs/modules/ROOT/partials/InfoNodes.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ INFO(Variable, Variables, VARIABLE, variable, variables,
7373
INFO(Field, Fields, FIELD, field, fields, The symbol is a field)
7474
INFO(Specialization, Specializations, SPECIALIZATION, specialization, specializations, The symbol is a template specialization)
7575
INFO(Friend, Friends, FRIEND, friend, friends, The symbol is a friend declaration)
76-
INFO(Enumerator, Enumerators, ENUMERATOR, enumerator, enumerators, The symbol is an enumerator)
76+
INFO(EnumConstant, EnumConstants, ENUM_CONSTANT, enumerator, enumerators, The symbol is an enumerator)
7777
INFO(Guide, Guides, GUIDE, guide, guides, The symbol is a deduction guide)
7878
INFO(Alias, Aliases, ALIAS, alias, aliases, The symbol is a namespace alias)
7979
INFO(Using, Usings, USING, using, usings, The symbol is a using declaration)

docs/mrdocs.schema.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
},
112112
"implementation-defined": {
113113
"default": [],
114-
"description": "Namespaces for symbols rendered as \"implementation-defined\". Symbols in these namespaces are not extracted and are rendered as \"implementation-defined\" in the documentation. This option is used to exclude symbols from the documentation that are considered part of the private API of the project.",
114+
"description": "Namespaces for symbols rendered as \"implementation-defined\". Symbols in these are rendered as \"implementation-defined\" in the documentation. This option is used to exclude symbols from the documentation that are considered part of the private API of the project. An \"implementation-defined\" symbol has no documentation page in the output. If any other symbol refers to it, the reference is rendered as \"implementation-defined\".",
115115
"items": {
116116
"type": "string"
117117
},
@@ -130,7 +130,7 @@
130130
},
131131
"inaccessible-members": {
132132
"default": "always",
133-
"description": "Determine whether inaccessible members should be extracted. When set to `always`, inaccessible members are always extracted. When set to `dependency`, inaccessible members are extracted only if they are referenced by the source code. When set to `never`, inaccessible members are never extracted.",
133+
"description": "Determine whether inaccessible members, such as private members of records, should be extracted. When set to `always`, inaccessible members are always extracted. When set to `dependency`, inaccessible members are extracted only if they are referenced by the source code. When set to `never`, inaccessible members are never extracted.",
134134
"enum": [
135135
"always",
136136
"dependency",
@@ -193,7 +193,7 @@
193193
},
194194
"referenced-declarations": {
195195
"default": "dependency",
196-
"description": "Determine whether external declarations should be extracted when they are referenced in the source code. When set to `always`, external declarations are always extracted. When set to `dependency`, external declarations are extracted only if they are referenced by the source code. When set to `never`, external declarations are never extracted.",
196+
"description": "Determine whether external declarations should be extracted when they are referenced in the source code. If this option is not `never`, a second pass happens in the extraction process to extract dependencies in the Corpus. When set to `always`, external declarations are always extracted. When set to `dependency`, external declarations are extracted only if they are referenced by the source code. When set to `never`, external declarations are never extracted.",
197197
"enum": [
198198
"always",
199199
"dependency",
@@ -211,7 +211,7 @@
211211
},
212212
"see-below": {
213213
"default": [],
214-
"description": "Namespaces for symbols rendered as \"see-below\". Symbols in these namespaces are not extracted and are rendered as \"see-below\" in the documentation. This option is used to exclude symbols from the documentation that are considered part of the private API of the project.",
214+
"description": "Namespaces for symbols rendered as \"see-below\". Symbols in these namespaces are rendered as \"see-below\" in the documentation. This option is used to exclude details about symbols from the documentation that are considered part of the private API of the project. In the documentation page for this symbol, the synopsis of the implementation of a \"see-below\" symbol is rendered as \"see-below\". When the symbol is a scope (such as a namespace or record), its members are not listed. The rest of the documentation is rendered as usual.",
215215
"items": {
216216
"type": "string"
217217
},

docs/website/render.js

+5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ if (!fs.existsSync(mrdocsExecutable)) {
4646
// Read panel snippet files and create documentation
4747
const absSnippetsDir = path.join(__dirname, 'snippets')
4848
for (let panel of data.panels) {
49+
console.log(`Generating documentation for panel ${panel.source}`)
50+
4951
// Find source file
5052
const sourcePath = path.join(absSnippetsDir, panel.source)
5153
assert(sourcePath.endsWith('.cpp'))
@@ -102,6 +104,9 @@ target_compile_features(${sourceBasename} PRIVATE cxx_std_23)
102104
// Delete these temporary files
103105
fs.rmSync(mrdocsOutput, {recursive: true});
104106
fs.unlinkSync(cmakeListsPath);
107+
108+
console.log(`Documentation generated successfully for panel ${panel.source}`)
109+
console.log(`====================================`)
105110
}
106111

107112
// Render the template with the data containing the snippet data

docs/website/snippets/mrdocs.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
source-root: .
2+
input:
3+
include:
4+
- .

include/mrdocs/Metadata.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
// All headers related to
1818
// metadata extracted from AST
1919

20-
#include <mrdocs/Metadata/Alias.hpp>
2120
#include <mrdocs/Metadata/Concept.hpp>
2221
#include <mrdocs/Metadata/Enum.hpp>
23-
#include <mrdocs/Metadata/Enumerator.hpp>
22+
#include <mrdocs/Metadata/EnumConstant.hpp>
2423
#include <mrdocs/Metadata/Expression.hpp>
2524
#include <mrdocs/Metadata/Field.hpp>
2625
#include <mrdocs/Metadata/Friend.hpp>
@@ -31,10 +30,11 @@
3130
#include <mrdocs/Metadata/Javadoc.hpp>
3231
#include <mrdocs/Metadata/Name.hpp>
3332
#include <mrdocs/Metadata/Namespace.hpp>
33+
#include <mrdocs/Metadata/NamespaceAlias.hpp>
3434
#include <mrdocs/Metadata/Overloads.hpp>
3535
#include <mrdocs/Metadata/Record.hpp>
36-
#include <mrdocs/Metadata/Specialization.hpp>
3736
#include <mrdocs/Metadata/Source.hpp>
37+
#include <mrdocs/Metadata/Specialization.hpp>
3838
#include <mrdocs/Metadata/Symbols.hpp>
3939
#include <mrdocs/Metadata/Template.hpp>
4040
#include <mrdocs/Metadata/Type.hpp>

include/mrdocs/Metadata/Concept.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <mrdocs/Metadata/Info.hpp>
1616
#include <mrdocs/Metadata/Expression.hpp>
1717
#include <mrdocs/Metadata/Source.hpp>
18+
#include <mrdocs/Metadata/Template.hpp>
1819

1920
namespace clang {
2021
namespace mrdocs {

include/mrdocs/Metadata/Enumerator.hpp renamed to include/mrdocs/Metadata/EnumConstant.hpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// Official repository: https://github.com/cppalliance/mrdocs
99
//
1010

11-
#ifndef MRDOCS_API_METADATA_ENUMERATOR_HPP
12-
#define MRDOCS_API_METADATA_ENUMERATOR_HPP
11+
#ifndef MRDOCS_API_METADATA_ENUMCONSTANT_HPP
12+
#define MRDOCS_API_METADATA_ENUMCONSTANT_HPP
1313

1414
#include <mrdocs/Platform.hpp>
1515
#include <mrdocs/Metadata/Expression.hpp>
@@ -21,10 +21,10 @@
2121
namespace clang {
2222
namespace mrdocs {
2323

24-
/** Info for enumerators.
24+
/** Info for enum constants.
2525
*/
26-
struct EnumeratorInfo
27-
: InfoCommonBase<InfoKind::Enumerator>
26+
struct EnumConstantInfo
27+
: InfoCommonBase<InfoKind::EnumConstant>
2828
, SourceInfo
2929
{
3030
/** The initializer expression, if any
@@ -33,7 +33,7 @@ struct EnumeratorInfo
3333

3434
//--------------------------------------------
3535

36-
explicit EnumeratorInfo(SymbolID ID) noexcept
36+
explicit EnumConstantInfo(SymbolID ID) noexcept
3737
: InfoCommonBase(ID)
3838
{
3939
}

include/mrdocs/Metadata/Alias.hpp renamed to include/mrdocs/Metadata/NamespaceAlias.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// Official repository: https://github.com/cppalliance/mrdocs
99
//
1010

11-
#ifndef MRDOCS_API_METADATA_ALIAS_HPP
12-
#define MRDOCS_API_METADATA_ALIAS_HPP
11+
#ifndef MRDOCS_API_METADATA_NAMESPACEALIAS_HPP
12+
#define MRDOCS_API_METADATA_NAMESPACEALIAS_HPP
1313

1414
#include <mrdocs/Platform.hpp>
1515
#include <mrdocs/Metadata/Info.hpp>
@@ -22,16 +22,16 @@ namespace mrdocs {
2222

2323
/** Info for namespace aliases.
2424
*/
25-
struct AliasInfo
26-
: InfoCommonBase<InfoKind::Alias>
25+
struct NamespaceAliasInfo
26+
: InfoCommonBase<InfoKind::NamespaceAlias>
2727
, SourceInfo
2828
{
2929
/** The aliased symbol. */
3030
std::unique_ptr<NameInfo> AliasedSymbol;
3131

3232
//--------------------------------------------
3333

34-
explicit AliasInfo(SymbolID ID) noexcept
34+
explicit NamespaceAliasInfo(SymbolID ID) noexcept
3535
: InfoCommonBase(ID)
3636
{
3737
}

include/mrdocs/Metadata/Source.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ struct MRDOCS_DECL
7272
//--------------------------------------------
7373

7474
Location(
75-
std::string_view filepath = "",
76-
std::string_view filename = "",
77-
unsigned line = 0,
78-
FileKind kind = FileKind::Source,
79-
bool documented = false)
75+
std::string_view const filepath = {},
76+
std::string_view const filename = {},
77+
unsigned const line = 0,
78+
FileKind const kind = FileKind::Source,
79+
bool const documented = false)
8080
: Path(filepath)
8181
, Filename(filename)
8282
, LineNumber(line)

include/mrdocs/Support/Error.hpp

+13-6
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ namespace detail
572572

573573
/// Check existing expected-like type
574574
# define MRDOCS_CHECK_VOID(var) \
575-
if (detail::failed(var)) { \
575+
if (detail::failed(var)) { \
576576
return Unexpected(detail::error(var)); \
577577
} \
578578
void(0)
@@ -585,13 +585,20 @@ namespace detail
585585
# define MRDOCS_CHECK(...) \
586586
MRDOCS_CHECK_GET_MACRO(__VA_ARGS__, MRDOCS_CHECK_MSG, MRDOCS_CHECK_VOID)(__VA_ARGS__)
587587

588-
# define MRDOCS_CHECK_OR(var, expr) \
589-
if (detail::failed(var)) { \
590-
return expr; \
588+
/// Check existing expected-like type and return custom value otherwise
589+
# define MRDOCS_CHECK_OR_VOID(var) \
590+
if (detail::failed(var)) { \
591+
return; \
591592
} \
592593
void(0)
593-
594-
594+
# define MRDOCS_CHECK_OR_VALUE(var, value) \
595+
if (detail::failed(var)) { \
596+
return value; \
597+
} \
598+
void(0)
599+
# define MRDOCS_CHECK_GET_OR_MACRO(_1, _2, NAME, ...) NAME
600+
# define MRDOCS_CHECK_OR(...) \
601+
MRDOCS_CHECK_GET_OR_MACRO(__VA_ARGS__, MRDOCS_CHECK_OR_VALUE, MRDOCS_CHECK_OR_VOID)(__VA_ARGS__)
595602
#endif
596603

597604

include/mrdocs/mrdocs.natvis

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
<AlternativeType Name="clang::mrdocs::FieldInfo"/>
3232
<AlternativeType Name="clang::mrdocs::SpecializationInfo"/>
3333
<AlternativeType Name="clang::mrdocs::FriendInfo"/>
34-
<AlternativeType Name="clang::mrdocs::EnumeratorInfo"/>
34+
<AlternativeType Name="clang::mrdocs::EnumConstantInfo"/>
3535
<AlternativeType Name="clang::mrdocs::GuideInfo"/>
36-
<AlternativeType Name="clang::mrdocs::AliasInfo"/>
36+
<AlternativeType Name="clang::mrdocs::NamespaceAliasInfo"/>
3737
<AlternativeType Name="clang::mrdocs::UsingInfo"/>
3838

3939
<DisplayString>{Kind,en} {Name} (ID = {id})</DisplayString>
@@ -49,9 +49,9 @@
4949
<ExpandedItem Condition="Kind == InfoKind::Field">(FieldInfo*)this,view(noinherit)</ExpandedItem>
5050
<ExpandedItem Condition="Kind == InfoKind::Specialization">(SpecializationInfo*)this,view(noinherit)</ExpandedItem>
5151
<ExpandedItem Condition="Kind == InfoKind::Friend">(FriendInfo*)this,view(noinherit)</ExpandedItem>
52-
<ExpandedItem Condition="Kind == InfoKind::Enumerator">(EnumeratorInfo*)this,view(noinherit)</ExpandedItem>
52+
<ExpandedItem Condition="Kind == InfoKind::Enumerator">(EnumConstantInfo*)this,view(noinherit)</ExpandedItem>
5353
<ExpandedItem Condition="Kind == InfoKind::Guide">(GuideInfo*)this,view(noinherit)</ExpandedItem>
54-
<ExpandedItem Condition="Kind == InfoKind::Alias">(AliasInfo*)this,view(noinherit)</ExpandedItem>
54+
<ExpandedItem Condition="Kind == InfoKind::NamespaceAlias">(NamespaceAliasInfo*)this,view(noinherit)</ExpandedItem>
5555
<ExpandedItem Condition="Kind == InfoKind::Using">(UsingInfo*)this,view(noinherit)</ExpandedItem>
5656
</Expand>
5757
</Type>

0 commit comments

Comments
 (0)