admin管理员组

文章数量:1410682

I'm trying to figure out how to generate documentation for partial classes, that exist in the same namespace, but are split across multiple files.

Made up example:

Filename: Payment.cs

namespace OrderProcessing

partial class OrderProcessor
{
    public void ProcessPayment()
    public void ApplyDiscounts()
    public void CalculateTaxes()
    public void RefundPayment()
}

Filename: Shipping.cs

namespace OrderProcessing

partial class OrderProcessor
{
    public void PrepareShipment()
    public void GenerateTrackingNumber()
}

When I build the documentation, all partial classes are merged into one single entry for OrderProcessor, and include all the methods. However, I want to split the documentation so that each file has its own separate section, with each their own mehods.

Current workaround:

  1. Rename the class in each file to match the filename:

Filename: Payment.cs

namespace OrderProcessing

public class Payment
{
    public void ProcessPayment()
    public void ApplyDiscounts()
    public void CalculateTaxes()
    public void RefundPayment()
}

Filename: Shipping.cs

namespace OrderProcessing

public class Shipping
{
    public void PrepareShipment()
    public void GenerateTrackingNumber()
}
  1. Modify docfx.json by overwriting the class name in the docfx.json , with a .md file for each class, to restore the intended name OrderProcessor.

docs/PaymentClassOverwrite.md

---
uid: OrderProcessing.Payment
name: OrderProcessor
syntax:
    content: public class OrderProcessor
---

docs/ShippingClassOverwrite.md

---
uid: OrderProcessing.Shipping
name: OrderProcessor
syntax:
    content: public class OrderProcessor
---
"build": {
    "content": [
      {
        "files": [
          "**/*.{md,yml}"
        ],
        "exclude": [
          "_site/**"
        ]
      }
    ],
    "overwrite": [
      {
        "files": [
          "docs/PaymentClassOverwrite.md",
          "docs/ShippingClassOverwrite.md"
      ]
      }
    ],
  1. Generate the documentation.

  2. Change the class names back to Orderprocessor in the source code.

Is there a better way to document partial classes separately in DocFX without renaming them in code ? Or is merging them into a single entry the only supported behavior ?

If this is not possible in DocFX, are there any other documentation tools that support documenting partial classes separately ? If anyone knows of a tool or has a relevant link, it would be helpful for considering a feature request for DocFX.

本文标签: How to Document Partial Classes Separately in DocFX (C)Stack Overflow