SearchBasedApiDocUrlResolver Class

Namespace
Kampute.DocToolkit.Routing
Assembly
  • Kampute.DocToolkit.dll

Definition

Resolves URLs to search engines or documentation repositories for code elements that lack structured documentation.
public class SearchBasedApiDocUrlResolver : RemoteApiDocUrlResolver, ILanguageSpecific
Inheritance
Implements

Remarks

The SearchBasedApiDocUrlResolver class generates search query URLs for code elements that don't have formal documentation or when the documentation location is unknown. It's particularly useful for:
  • Third-party libraries without published documentation
  • Legacy or uncommon APIs with limited documentation
  • Custom or internal APIs where documentation might exist but in fragmented locations
This resolver constructs URLs with search query parameters, where the parameter name is specified in the constructor (defaults to "q"). The search term is the fully-qualified name of the code element, which can be optionally formatted using a specified programming language.

To control which APIs this resolver handles, add namespace patterns to the RemoteApiDocUrlResolver.NamespacePatterns collection, using exact matches (e.g., "Contoso.Services"), wildcard patterns (e.g., "Contoso.*"), or the universal match pattern "*".

This resolver deliberately does not attempt to resolve URLs for explicitly implemented interface members, constructed generic types, and types with modifiers. This is because such cases are better understood by breaking them down into their component parts. For example, an implementation like ICollection<DateTime>.Count is better resolved through separate links to:
  1. The ICollection<T> interface documentation
  2. The DateTime type documentation
  3. The Count property documentation on the interface
This approach provides a more robust learning path for developers trying to understand these implementation relationships.

Constructors

SearchBasedApiDocUrlResolver(Uri, string)Initializes a new instance of the SearchBasedApiDocUrlResolver class with the specified search query parameter name.

Properties

LanguageGets or sets the programming language used for formatting the search term.
ParamNameGets the name of the search query parameter used in constructing URLs.

Methods

BuildSearchUrl(string)Creates a search URL for the specified term.
ResolveMemberUrl(IMember)Attempts to resolve the documentation URL for the specified member.
ResolveNamespaceUrl(string)Attempts to resolve the documentation URL for the specified namespace.

Extension Methods

TryGetUrlByCodeReference(this IApiDocUrlProvider, string, out Uri)Attempts to retrieves the documentation URL for the specified code reference.

See Also