-
Notifications
You must be signed in to change notification settings - Fork 20
Implements using directives, using declarations and namespace aliases #545
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// Copyright (c) 2024 Fernando Pelliccioni (fpelliccioni@gmail.com) | ||
// | ||
// Official repository: https://github.com/cppalliance/mrdocs | ||
// | ||
|
||
#ifndef MRDOCS_API_METADATA_ALIAS_HPP | ||
#define MRDOCS_API_METADATA_ALIAS_HPP | ||
|
||
#include <mrdocs/Platform.hpp> | ||
#include <mrdocs/Metadata/Info.hpp> | ||
#include <mrdocs/Metadata/Source.hpp> | ||
#include <mrdocs/Metadata/Type.hpp> | ||
#include <utility> | ||
|
||
namespace clang { | ||
namespace mrdocs { | ||
|
||
/** Info for namespace aliases. | ||
*/ | ||
struct AliasInfo | ||
: IsInfo<InfoKind::Alias> | ||
, SourceInfo | ||
{ | ||
/** The aliased symbol. */ | ||
std::unique_ptr<NameInfo> AliasedSymbol; | ||
|
||
//-------------------------------------------- | ||
|
||
explicit AliasInfo(SymbolID ID) noexcept | ||
: IsInfo(ID) | ||
{ | ||
} | ||
}; | ||
|
||
} // mrdocs | ||
} // clang | ||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fpelliccioni marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// | ||
// Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// Copyright (c) 2024 Fernando Pelliccioni (fpelliccioni@gmail.com) | ||
// | ||
// Official repository: https://github.com/cppalliance/mrdocs | ||
// | ||
|
||
#ifndef MRDOCS_API_METADATA_USING_HPP | ||
#define MRDOCS_API_METADATA_USING_HPP | ||
|
||
#include <mrdocs/Platform.hpp> | ||
#include <mrdocs/Metadata/Info.hpp> | ||
#include <mrdocs/Metadata/Source.hpp> | ||
#include <mrdocs/Metadata/Type.hpp> | ||
#include <vector> | ||
#include <utility> | ||
|
||
namespace clang { | ||
namespace mrdocs { | ||
|
||
enum class UsingClass | ||
{ | ||
Normal = 0, // using | ||
Typename, // using typename | ||
Enum, // using enum | ||
Namespace // using namespace (using directive) | ||
}; | ||
|
||
static constexpr | ||
std::string_view | ||
toString(UsingClass const& value) | ||
{ | ||
switch (value) | ||
{ | ||
case UsingClass::Normal: return "normal"; | ||
case UsingClass::Typename: return "typename"; | ||
case UsingClass::Enum: return "enum"; | ||
case UsingClass::Namespace: return "namespace"; | ||
} | ||
return "unknown"; | ||
} | ||
|
||
/** Info for using declarations and directives. | ||
*/ | ||
struct UsingInfo | ||
: IsInfo<InfoKind::Using>, | ||
SourceInfo | ||
{ | ||
/** The kind of using declaration/directive. */ | ||
UsingClass Class = UsingClass::Normal; | ||
|
||
/** The symbols being "used". */ | ||
std::vector<SymbolID> UsingSymbols; | ||
fpelliccioni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** The qualifier for a using declaration/directive. */ | ||
std::unique_ptr<NameInfo> Qualifier; | ||
|
||
//-------------------------------------------- | ||
|
||
explicit UsingInfo(SymbolID ID) noexcept | ||
: IsInfo(ID) | ||
{ | ||
} | ||
}; | ||
|
||
} // mrdocs | ||
} // clang | ||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
share/mrdocs/addons/generator/asciidoc/partials/signature/alias.adoc.hbs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
namespace {{symbol.name}} = {{>name-info symbol.aliasedSymbol}} |
5 changes: 5 additions & 0 deletions
5
share/mrdocs/addons/generator/asciidoc/partials/signature/using.adoc.hbs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{{#if (eq symbol.class "namespace")}} | ||
using namespace {{#if symbol.qualifier}}{{>name-info symbol.qualifier}}::{{/if}}{{symbol.name}} | ||
{{else}} | ||
using {{#if (eq symbol.class "typename")}}typename {{/if}}{{#if (eq symbol.class "enum")}}enum {{/if}}{{#if symbol.qualifier}}{{>name-info symbol.qualifier}}::{{/if}}{{symbol.name}} | ||
{{/if}} |
20 changes: 20 additions & 0 deletions
20
share/mrdocs/addons/generator/asciidoc/partials/symbols/alias.adoc.hbs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{!-- alias --}} | ||
= {{>nested-name-specifier symbol=symbol.parent}}{{symbol.name}} | ||
|
||
{{symbol.doc.brief}} | ||
|
||
== Synopsis | ||
|
||
{{>source dcl=(primary_location symbol)}} | ||
|
||
[source,cpp,subs="verbatim,macros,-callouts"] | ||
---- | ||
{{>signature/alias symbol=symbol}}; | ||
---- | ||
|
||
{{#if symbol.doc.description}} | ||
== Description | ||
|
||
{{symbol.doc.description}} | ||
|
||
{{/if}} |
31 changes: 31 additions & 0 deletions
31
share/mrdocs/addons/generator/asciidoc/partials/symbols/using.adoc.hbs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{{!-- symbols/using.adoc.hbs --}} | ||
= Using {{#if (eq symbol.class "namespace")}}Directive: {{symbol.qualifier.name}}{{else}}Declaration: {{symbol.name}}{{/if}} | ||
|
||
{{symbol.doc.brief}} | ||
|
||
== Synopsis | ||
|
||
{{>source dcl=(primary_location symbol)}} | ||
|
||
[source,cpp,subs="verbatim,macros,-callouts"] | ||
---- | ||
{{>signature/using symbol=symbol}}; | ||
---- | ||
|
||
{{#if symbol.doc.description}} | ||
== Description | ||
|
||
{{symbol.doc.description}} | ||
|
||
{{/if}} | ||
|
||
{{#unless (eq symbol.class "namespace")}} | ||
== Introduced Symbols | ||
|
||
|=== | ||
| Name | ||
{{#each symbol.symbols}} | ||
| {{name}} | ||
{{/each}} | ||
|=== | ||
{{/unless}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.