Browse Source

Added support for the Doxygen tag for making bold text. (#889)

pull/893/head
Kimon Topouzidis 8 years ago committed by Dimitar Dobrev
parent
commit
052b2b3a86
  1. 33
      src/Generator.Tests/AST/TestAST.cs
  2. 12
      src/Generator/Generators/CSharp/CSharpCommentPrinter.cs
  3. 15
      tests/Native/AST.h

33
src/Generator.Tests/AST/TestAST.cs

@ -34,16 +34,16 @@ namespace CppSharp.Generator.Tests.AST @@ -34,16 +34,16 @@ namespace CppSharp.Generator.Tests.AST
var func = AstContext.FindFunction("TestParameterProperties").FirstOrDefault();
Assert.IsNotNull(func);
var paramNames = new [] { "a", "b", "c" };
var paramTypes = new []
{
var paramNames = new[] { "a", "b", "c" };
var paramTypes = new[]
{
new QualifiedType(new BuiltinType(PrimitiveType.Bool)),
new QualifiedType(
new PointerType()
{
Modifier = PointerType.TypeModifier.LVReference,
QualifiedPointee = new QualifiedType(
new BuiltinType(PrimitiveType.Short),
new BuiltinType(PrimitiveType.Short),
new TypeQualifiers { IsConst = true })
}),
new QualifiedType(
@ -255,12 +255,12 @@ namespace CppSharp.Generator.Tests.AST @@ -255,12 +255,12 @@ namespace CppSharp.Generator.Tests.AST
Assert.IsNotNull(twoParamMethod);
Assert.IsInstanceOf<TemplateParameterType>(twoParamMethod.Parameters[0].Type);
Assert.IsInstanceOf<TemplateParameterType>(twoParamMethod.Parameters[1].Type);
Assert.AreEqual(twoParamMethodTemplate.Parameters[0],
((TemplateParameterType)twoParamMethod.Parameters[0].Type).Parameter);
Assert.AreEqual(twoParamMethodTemplate.Parameters[0],
((TemplateParameterType) twoParamMethod.Parameters[0].Type).Parameter);
Assert.AreEqual(twoParamMethodTemplate.Parameters[1],
((TemplateParameterType)twoParamMethod.Parameters[1].Type).Parameter);
Assert.AreEqual(0, ((TemplateParameterType)twoParamMethod.Parameters[0].Type).Index);
Assert.AreEqual(1, ((TemplateParameterType)twoParamMethod.Parameters[1].Type).Index);
((TemplateParameterType) twoParamMethod.Parameters[1].Type).Parameter);
Assert.AreEqual(0, ((TemplateParameterType) twoParamMethod.Parameters[0].Type).Index);
Assert.AreEqual(1, ((TemplateParameterType) twoParamMethod.Parameters[1].Type).Index);
}
[Test]
@ -405,6 +405,21 @@ namespace CppSharp.Generator.Tests.AST @@ -405,6 +405,21 @@ namespace CppSharp.Generator.Tests.AST
// <para>feeding the input stream for the debugger, or NULL if there is</para>
// <para>no string for this control key.</para>
// </returns>".Replace("\r", string.Empty), commentMethod.Replace("\r", string.Empty));
var methodTestDoxygen = @class.Methods.First(m => m.Name == "TestDoxygenBoldTag");
var commentMethodDoxygen = methodTestDoxygen.Comment.FullComment.CommentToString(CommentKind.BCPLSlash);
Assert.AreEqual(@"/// <summary>Attach to a process by name.</summary>
/// <remarks>
/// <para>This function implies that a future call to SBTarget::Attach(...)</para>
/// <para>will be synchronous.</para>
/// </remarks>
/// <param name=""path"">A full or partial name for the process to attach to.</param>
/// <param name=""wait_for"">
/// <para>If<c>false,</c></para>
/// <para>attach to an existing process whose name matches.</para>
/// <para>If<c>true,</c></para>
/// <para>then wait for the next process whose name matches.</para>
/// </param>".Replace("\r", string.Empty), commentMethodDoxygen.Replace("\r", string.Empty));
}
[Test]

12
src/Generator/Generators/CSharp/CSharpCommentPrinter.cs

@ -81,6 +81,17 @@ namespace CppSharp.Generators.CSharp @@ -81,6 +81,17 @@ namespace CppSharp.Generators.CSharp
case DocumentationCommentKind.InlineContentComment:
break;
case DocumentationCommentKind.InlineCommandComment:
var lastSection = sections.Last();
var inlineCommand = (InlineCommandComment) comment;
if (inlineCommand.CommandKind == CommentCommandKind.B)
{
var argText = $"<c>{inlineCommand.Arguments[0].Text}</c>";
if (lastSection.Lines.Count > 0)
lastSection.Lines[lastSection.Lines.Count - 1] += argText;
else
lastSection.Lines.Add(argText);
}
break;
case DocumentationCommentKind.VerbatimBlockLineComment:
break;
@ -122,7 +133,6 @@ namespace CppSharp.Generators.CSharp @@ -122,7 +133,6 @@ namespace CppSharp.Generators.CSharp
private static string FormatComment(List<Section> sections, CommentKind kind)
{
var commentPrefix = Comment.GetMultiLineCommentPrologue(kind);
var commentBuilder = new StringBuilder();
foreach (var section in sections.Where(s => s.Lines.Count > 0))
{

15
tests/Native/AST.h

@ -153,6 +153,21 @@ public: @@ -153,6 +153,21 @@ public:
/// no string for this control key.
//----------------------------------------------------------------------
const char * GetIOHandlerControlSequence(char ch);
//------------------------------------------------------------------
/// Attach to a process by name.
///
/// This function implies that a future call to SBTarget::Attach(...)
/// will be synchronous.
///
/// @param[in] path
/// A full or partial name for the process to attach to.
///
/// @param[in] wait_for
/// If \b false, attach to an existing process whose name matches.
/// If \b true, then wait for the next process whose name matches.
//------------------------------------------------------------------
const char * TestDoxygenBoldTag(char ch);
};
template <typename T>

Loading…
Cancel
Save