docfx icon indicating copy to clipboard operation
docfx copied to clipboard

Can't update document links by overriding UpdateHref method

Open skudnoff opened this issue 8 years ago • 4 comments

DocFX Version Used: 2.31

Template used: any template, default or custom Steps to Reproduce:

  1. Create custom ConceptualDocumentProcessor
  2. Override the UpdateHref method and update Href of documents like this for example:
public override void UpdateHref(FileModel model, IDocumentBuildContext context) {
    if(model.Uids.Length > 0) {
        model.Properties.XrefSpec.Href = $"{model.Uids[0].Name}.md";
    }
}

Expected Behavior: All links to Conceptual documents are updated correctly accordingly to this code everywhere. In xrefmap.yml, Toc.html and other documents.

Actual Behavior: In xrefmap.yml all link are updated correctly. In Toc.html only part of them is updated every time in random order.

Looks like a bug with parallel document processing or I'm doing something wrong. I'm using custom UpdateHref method in DocumentProcessor because CustomLinkResolver doesn't know about Uid of target document. And I need custom links to hide content behind web application with specific links format.

skudnoff avatar Feb 17 '18 11:02 skudnoff

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Mar 06 '19 05:03 stale[bot]

Sorry for the terribly late reply... I do not get what is your scenario and why it can work partially to update model.Properties.XrefSpec.Href. For conceptual and TOC, as them ends with .html, there href is updated here when parsing the HTML DOM: https://github.com/dotnet/docfx/blob/2e0dd0b1a4aaac2e93ceaec9c792d6521209b855/src/Microsoft.DocAsCode.Build.Engine/TemplateProcessors/TemplateModelTransformer.cs#L373

superyyrrzz avatar Mar 10 '19 15:03 superyyrrzz

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week if no further activity occurs.

stale[bot] avatar Jun 08 '19 16:06 stale[bot]

Closing this issue after a prolonged period of inactivity. If you still think this issue is relevant, please feel free to ping a maintainer or leave a comment.

stale[bot] avatar Jun 15 '19 17:06 stale[bot]