私は動的コード ライターを作成しており、XML ドキュメントを書き込む関数に取り組んでいます。ドキュメントをフォーマットする関数が望ましくない末尾に追加されていることを除いて、すべて問題ありません。また、句読点で分割する必要もあります。
現在のフォーマット機能:
public static String FormatForXmlDocumentation(String xmlLine, Int32 spacing,
Int32 length = 120)
{
if (!string.IsNullOrEmpty(xmlLine))
{
var regex = new Regex(@".{0," + length.ToString() + "}", RegexOptions.Multiline);
return regex.Replace(xmlLine, "$0\r\n" + string.Empty.PadRight(spacing) + "/// ");
}
return null;
}
テスト コード ("!" は終了を示します):
Console.WriteLine(RenderForCode.FormatForXmlDocumentation(
@"Data info: Type: <see cref=""System.Nullable`1[System.Double]""/>; Nullable: false; Default: 101.23d; Low: 100d; High: 200d", 4, 40
) + "!");
現在の出力:
Data info: Type: <see cref="System.Nulla
/// ble`1[System.Double]"/>; Nullable: false
/// ; Default: 101.23d; Low: 100d; High: 200
/// d
///
/// !
望ましい出力:
Data info: Type: <see cref="System.
/// Nullable`1[System.Double]"/>; Nullable:
/// false; Default: 101.23d; Low: 100d;
/// High: 200d!
呼び出し元の関数が最初の行のプレフィックスを処理することに注意してください。