-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dgeni): automatically generate API doc links for code span in ma…
…rkdown (#2964)
- Loading branch information
Showing
8 changed files
with
68 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { | ||
Processor, | ||
Document, | ||
} from 'dgeni'; | ||
|
||
export const COLLECT_LINKABLE_SYMBOLS_PROCESSOR_NAME = 'collectLinkableSymbols'; | ||
|
||
/** | ||
* Stores a list of symbols and their paths. | ||
*/ | ||
export class CollectLinkableSymbolsProcessor implements Processor { | ||
private static readonly _symbols = new Map<string, string>(); | ||
|
||
public static get symbols(): ReadonlyMap<string, string> { | ||
return this._symbols; | ||
} | ||
|
||
name = COLLECT_LINKABLE_SYMBOLS_PROCESSOR_NAME; | ||
$runAfter = ['paths-computed']; | ||
$runBefore = ['markdown']; | ||
|
||
constructor(private log, private createDocMessage) {} | ||
|
||
$process(docs: Document[]): Document[] { | ||
docs.forEach((doc) => { | ||
if (CollectLinkableSymbolsProcessor._symbols.get(doc.name)) { | ||
this.log.warn(this.createDocMessage(`Linkable symbol collision for name ${doc.name}. Existing path: ${CollectLinkableSymbolsProcessor._symbols.get(doc.name)}, new path: ${doc.path}`)); | ||
} | ||
CollectLinkableSymbolsProcessor._symbols.set(doc.name, doc.path); | ||
}); | ||
|
||
return docs; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters