Skip to content
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

support implied whitelist rules #812

Merged
merged 4 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions docs/modules/ROOT/pages/config-file.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ see-below:
- 'my_library::see_below::**'
----

Symbols are only checked against the `implementation-detail` and `see-below` options if they match the `include-symbols` option.

[,cpp]
----
namespace my_library
Expand All @@ -184,6 +182,21 @@ namespace my_library
}
----

=== Whitelisting Rules

The rules for whitelisting symbols (`include-symbols`, `implementation-defined`, and `see-below`) are less strict than the rules for blacklisting symbols (`exclude-symbols`). A symbol is considered whitelisted if it matches any of the following conditions:

1. The symbol strictly matches one of the patterns.
** For instance, the patterns `std::vector` and `std::*` both match `std::vector` strictly.
2. The symbol is a parent namespace of an included symbol.
** For instance, the pattern `std::filesystem::*` also includes `std` and `std::filesystem`.
3. The parent symbol is also included.
** For instance, the pattern `std::*` also matches `std::vector::iterator` because `std::vector::iterator` is a member of `std::vector`, which is matches the pattern.
4. The symbol is a child of a literal pattern representing a namespace.
** For instance, the literal pattern `std` matches `std::filesystem::path::iterator` because `std` is a literal pattern matching a namespace. In other words, these literal patterns represent the namespace and its subnamespaces as if the pattern were `std::**`.

For exclusion rules, the symbol must strictly match the pattern to be excluded.

[#config-options-reference]
== Reference

Expand Down
36 changes: 36 additions & 0 deletions include/mrdocs/Support/Glob.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ class GlobPattern {
bool
matchPatternPrefix(std::string_view prefix, char delimiter) const;

/** Checks if the glob pattern is a literal string.

This function determines if the glob pattern does not contain
any special characters. In other words, it matches a single string.

@return true if the glob pattern is a literal string, false otherwise.
*/
bool
isLiteral() const;

/** Returns the glob pattern.

@return The glob pattern as a string view.
Expand Down Expand Up @@ -185,6 +195,19 @@ class PathGlobPattern {
return glob_.matchPatternPrefix(prefix, '/');
}

/** Checks if the glob pattern is a literal string.

This function determines if the glob pattern does not contain
any special characters. In other words, it matches a single string.

@return true if the glob pattern is a literal string, false otherwise.
*/
bool
isLiteral() const
{
return glob_.isLiteral();
}

/** Returns the glob pattern.

@return The glob pattern as a string view.
Expand Down Expand Up @@ -276,6 +299,19 @@ class SymbolGlobPattern {
return glob_.matchPatternPrefix(prefix, ':');
}

/** Checks if the glob pattern is a literal string.

This function determines if the glob pattern does not contain
any special characters. In other words, it matches a single string.

@return true if the glob pattern is a literal string, false otherwise.
*/
bool
isLiteral() const
{
return glob_.isLiteral();
}

/** Returns the glob pattern.

@return The glob pattern as a string view.
Expand Down
Loading