dotnet / docfx

Static site generator for .NET API documentation.
https://dotnet.github.io/docfx/
MIT License
4.02k stars 854 forks source link

[Bug] globalNamespaceID and filter yml filter all API in a project regardless of namespace #9303

Open RobJessop opened 11 months ago

RobJessop commented 11 months ago

Describe the bug Using the following metadata settings in my config file:

"filter": "filter.yml",
"globalNamespaceID": "Global Namespace"

And the following rule in my filter config:

apiRules:
- exclude:
    uidRegex: ^Global Namespace.*
    type: Namespace

Causes all API to be filtered out of my project, across all namespaces.

To Reproduce Steps to reproduce the behavior:

  1. Unzip docfx_project.zip
  2. Build it.

Expected behavior ClassLibrary1.Class1.xPlusOne is documented.

Context (please complete the following information):

Additional context In our previous version of DocFX, 2.59.x, ClassLibrary1.Class1.xPlusOne is documented. What 2.70.0 is doing may be correct behavior, as I'm unsure of exactly what the global namespace is in the context of DocFX filtering, but this behavior change is unexpected.

filzrev commented 7 months ago

About my environment. (Windows + Latest docfx version)

This seems to be solved by changing the exclude type from namespace to type.

Background. API filter rules are applied recursively to the symbol's hierarchy. https://dotnet.github.io/docfx/docs/dotnet-api-docs.html?q=filterconfig#filter-apis

API filters are hierarchical when a namespace is excluded, all types/members defined in that namespace would also be excluded. Similarly, if a type is excluded, any members defined in the type would also be excluded.

So if you specify an excluding namespace uid with "type": "namespace". Then all types are excluded.

filzrev commented 3 months ago

Similar issue is reported at #9978. And it seems to be resolved by excluding by type: Type. and modifying regex.

- exclude:
    uidRegex: ^Global\.
    type: Type