Open Krusty93 opened 1 year ago
I think they changed how namespace filters work so one can exclude all child namespaces with a single rule. My guess is that if you change the order of your filter rules and put the rule to include ConsoleApp1.Domain.Models
, it should work.
@OscarAbraham thanks for feedback. However, I tried reversing the apiRules as you suggested , but it still doesn't work
apiRules:
- exclude:
uidRegex: ^ConsoleApp1\.Domain
- include:
uidRegex: ^ConsoleApp1\.Domain\.Models
@Krusty93 Sorry. I don't know why I thought it'd work.
@Krusty93 Sorry. I don't know why I thought it'd work.
No problem
In my opinion, this is the line that introduced the bug in PR #8408:
public bool IncludeApi(ISymbol symbol)
{
return IsSymbolAccessible(symbol) && IncludeApiCore(symbol);
bool IncludeApiCore(ISymbol symbol)
{
return _cache.GetOrAdd(symbol, _ => _options.IncludeApi?.Invoke(_) switch
{
SymbolIncludeState.Include => true,
SymbolIncludeState.Exclude => false,
_ => IncludeApiDefault(symbol),
});
}
bool IncludeApiDefault(ISymbol symbol)
{
if (_filterRule is not null && !_filterRule.CanVisitApi(RoslynFilterData.GetSymbolFilterData(symbol)))
return false;
return symbol.ContainingSymbol is null || IncludeApiCore(symbol.ContainingSymbol);
}
}
CanVisitApi
returns true because the apiRules
has an include
rule on the ConsoleApp1.Domain.Models
folder; however, the method is called again recursively passing the ContainingSymbol
as argumen that has the value of ConsoleApp1.Domain
. This value is not accepted, so it returns false
. For this reason, the flow ends up excluding the "more specific" namespace, being in contrast with what the documentation says.
I'm encountering the same problem, the include doesn't seem to work at all.
I just ran into the same issue with DocFx V2.71.0 My use case is that I only want to document things in a specific Namespace. In order to do so I have to 1st exclude everything, and then include the namespace I want (at least I understand the documentation like that). This is what I came up with:
apiRules:
- include:
uidRegex: ^Company\.Product\.Component\.
#type: Namespace
- exclude:
uidRegex: .*
#type: Namespace
I tried it with the type: Namespace
and without, I changed the order, ...
But I get everything unfiltered (I I reverse the order), or I get nothing with the warning: No .NET API detected for...
This issue is expected to be fixed in latest version of docfx. (By #9666)
Describe the bug I use DocFx to document a specific namespace in my dotnet project.
To achieve my goal I have a
filterConfig.yml
file where I exclude everything but what I need:But unfortunately, the produced documentation is empty because the last
exclude
rule is removing everything.I cloned the source code to attach the debugger and I saw that the class
SymbolFilter
(methodIncludeApi
) is correctly validating my rules, but then it checks for theContainingSymbol
as well. And being theModels
a child of theDomain
namespace, this obviously breaks my rules invalidating theinclude
one.This didn't happen with the v2.61.0 and according to the documentation this approach shall work.
To Reproduce Create a dotnet console app
MyApp
and two classes in two different namespaces:Run
docfx init --quiet
Fill the
metadata
property of thedocfx.json
file as follow:And create in the same folder a
filterConfig.yml
file:Run the
serve
command. Generated documentation will be emptyExpected behavior Generated documentation shall contain documentation for the
ConsoleApp1.Domain.Models
namespace (Class1
).To have a test, perform the same steps as above but with the 2.61.0 version installed.
Context:
OS: Windows
Docfx version: [e.g. 2.62.x]
.NET version: NET 6.0
docfx.json
configAdditional context Add any other context about the problem here.