Skip to content

Commit 554c3db

Browse files
committed
update docs
1 parent de79660 commit 554c3db

File tree

1 file changed

+46
-34
lines changed

1 file changed

+46
-34
lines changed

docs/docs/dotnet-api-docs.md

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ To disable markdown parsing while processing XML tags, set `shouldSkipMarkup` to
146146
}
147147
```
148148

149+
In addition, docfx supports these C# documentation comments:
150+
151+
### `<exclude>`
152+
149153
## Filter APIs
150154

151155
Docfx shows only the public accessible types and methods callable from another assembly. It also has a set of [default filtering rules](https://github.com/dotnet/docfx/blob/main/src/Docfx.Dotnet/Resources/defaultfilterconfig.yml) that excludes common API patterns based on attributes such as `[EditorBrowsableAttribute]`.
@@ -154,45 +158,18 @@ To disable the default filtering rules, set the `disableDefaultFilter` property
154158

155159
To show private methods, set the `includePrivateMembers` config to `true`. When enabled, internal only langauge keywords such as `private` or `internal` starts to appear in the declaration of all APIs, to accurately reflect API accessibility.
156160

157-
There are two ways of customizing the API filters:
161+
### The `<exclude />` documentation comment
158162

159-
### Custom with Code
163+
The `<exclude />` documentation comment excludes the type or member on a per API basis using C# documentation comment:
160164

161-
To use a custom filtering with code:
162-
163-
1. Use docfx .NET API generation as a NuGet library:
164-
165-
```xml
166-
<PackageReference Include="Docfx.Dotnet" Version="2.62.0" />
165+
```csharp
166+
/// <exclude />
167+
public class Foo { }
167168
```
168169

169-
2. Configure the filter options:
170+
### Custom filter rules
170171

171-
```cs
172-
var options = new DotnetApiOptions
173-
{
174-
// Filter based on types
175-
IncludeApi = symbol => ...
176-
177-
// Filter based on attributes
178-
IncludeAttribute = symbol => ...
179-
}
180-
181-
await DotnetApiCatalog.GenerateManagedReferenceYamlFiles("docfx.json", options);
182-
```
183-
184-
The filter callbacks takes an [`ISymbol`](https://learn.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.isymbol?view=roslyn-dotnet) interface and produces an [`SymbolIncludeState`](../api/Docfx.Dotnet.SymbolIncludeState.yml) enum to choose between include the API, exclude the API or use the default filtering behavior.
185-
186-
The callbacks are raised before applying the default rules but after processing type accessibility rules. Private types and members cannot be marked as include unless `includePrivateMembers` is true.
187-
188-
Hiding the parent symbol also hides all of its child symbols, e.g.:
189-
- If a namespace is hidden, all child namespaces and types underneath it are hidden.
190-
- If a class is hidden, all nested types underneath it are hidden.
191-
- If an interface is hidden, explicit implementations of that interface are also hidden.
192-
193-
### Custom with Filter Rules
194-
195-
To add additional filter rules, add a custom YAML file and set the `filter` property in `docfx.json` to point to the custom YAML filter:
172+
To bulk filter APIs with custom filter rules, add a custom YAML file and set the `filter` property in `docfx.json` to point to the custom YAML filter:
196173

197174
```json
198175
{
@@ -265,3 +242,38 @@ apiRules:
265242
```
266243

267244
Where the `ctorArguments` property specifies a list of match conditions based on constructor parameters and the `ctorNamedArguments` property specifies match conditions using named constructor arguments.
245+
246+
247+
### Custom code filter
248+
249+
To use a custom filtering with code:
250+
251+
1. Use docfx .NET API generation as a NuGet library:
252+
253+
```xml
254+
<PackageReference Include="Docfx.Dotnet" Version="2.62.0" />
255+
```
256+
257+
2. Configure the filter options:
258+
259+
```cs
260+
var options = new DotnetApiOptions
261+
{
262+
// Filter based on types
263+
IncludeApi = symbol => ...
264+
265+
// Filter based on attributes
266+
IncludeAttribute = symbol => ...
267+
}
268+
269+
await DotnetApiCatalog.GenerateManagedReferenceYamlFiles("docfx.json", options);
270+
```
271+
272+
The filter callbacks takes an [`ISymbol`](https://learn.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.isymbol?view=roslyn-dotnet) interface and produces an [`SymbolIncludeState`](../api/Docfx.Dotnet.SymbolIncludeState.yml) enum to choose between include the API, exclude the API or use the default filtering behavior.
273+
274+
The callbacks are raised before applying the default rules but after processing type accessibility rules. Private types and members cannot be marked as include unless `includePrivateMembers` is true.
275+
276+
Hiding the parent symbol also hides all of its child symbols, e.g.:
277+
- If a namespace is hidden, all child namespaces and types underneath it are hidden.
278+
- If a class is hidden, all nested types underneath it are hidden.
279+
- If an interface is hidden, explicit implementations of that interface are also hidden.

0 commit comments

Comments
 (0)