MarkdownAddressingStrategy Class

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

Definition

Provides an abstract base class for Markdown-based addressing strategies that organize documentation pages as a hierarchy of pages named after their titles.
public abstract class MarkdownAddressingStrategy : AddressingStrategy, ILanguageSpecific, IContextualAddressingStrategy
Inheritance
Implements
Inherited by

Remarks

This class defines the page structure shared by Markdown publishing targets such as wikis, where the name of a page is derived from its title and the pages nested under a page are placed in a folder with the same name:
  • Each namespace has a page named after the namespace.
  • Each type has a page named after the type, nested under the page of its namespace.
  • Type members are documented on the page of their declaring type, and are addressed by the anchor of their heading.
  • Each topic has a page named after its title, nested under the page of its parent topic.
When MarkdownAddressingOptions.MainTopicId is set, all other pages are nested under the page of the main topic. When MarkdownAddressingOptions.ApiTopicId is set, the namespace pages are nested under the page of the API topic.

Derived classes define how a title becomes a page name by implementing EncodePageName(string), and can override EncodeFragmentIdentifier(string) when the publishing target generates heading anchors differently from GitHub and GitLab. They can also override the methods that construct the page paths to change the page structure.

A type member is addressed by the anchor of a heading whose text is the member signature formatted by Language with NameQualifier.None. Renderers must therefore write that heading for each member on the page of its declaring type, so that the generated links reach the member.

Thread Safety

Public instance members can be considered thread-safe if neither MarkdownAddressingOptions.MainTopicId nor MarkdownAddressingOptions.ApiTopicId is set in the construction options of the instance. If either property is set, instance members are only thread-safe if the instance is fully initialized (that is, IContextualAddressingStrategy.InitializeWithContext(IDocumentationContext) has been called) before any other method is accessed, and there is no concurrent access during or before initialization.

The class is not thread-safe otherwise, because it contains a mutable context field and uses lazy initialization that depends on this field, without synchronization.

Constructors

MarkdownAddressingStrategy(MarkdownAddressingOptions)Initializes a new instance of the MarkdownAddressingStrategy class.

Properties

ApiPathGets the file path of the API documentation page.
GranularityGets the page granularity used for organizing documentation content.
LanguageGets the programming language formatter used for formatting member names.
MainPathGets the file path of the main documentation page.

Methods

EncodeFragmentIdentifier(string)Converts the text of a heading to the fragment identifier that addresses the heading.
EncodePageName(string)Converts the specified title to the name of a page, as it appears in the file path and URL of the page.
GetNamespacePath(string)Retrieves the relative documentation path for the specified namespace.
GetTopicPath(ITopic)Retrieves the relative documentation path for the specified topic.
GetTypePath(IType)Retrieves the relative documentation path for the specified type.
IsAddressable(IMember)Determines whether the specified member can be addressed by this strategy.
IsMainTopic(ITopic)Determines whether the specified topic is the main topic of the documentation.
TryResolveMemberAddress(IMember, out IResourceAddress)Attempts to resolve the address of the documentation content for the specified member.
TryResolveNamespaceAddress(string, out IResourceAddress)Attempts to resolve the address of the documentation content for the specified namespace.
TryResolveTopicAddress(ITopic, out IResourceAddress)Attempts to resolve the address for the documentation content of the specified topic.

Explicit Interface Implementations

IContextualAddressingStrategy.InitializeWithContext(IDocumentationContext)Binds the addressing strategy to the specified documentation context.

Extension Methods

TryResolveAddressByCodeReference(this IDocumentAddressingStrategy, string, out IResourceAddress)Attempts to resolve the address of the documentation content for the specified code reference.