Merge pull request #1641 from joelmartinez/docs-monodoc-mdoc-patches
authorJonathan Pryor <jonpryor@vt.edu>
Sat, 21 Mar 2015 12:23:22 +0000 (08:23 -0400)
committerJonathan Pryor <jonpryor@vt.edu>
Sat, 21 Mar 2015 12:23:22 +0000 (08:23 -0400)
monodoc/mdoc patches

mcs/class/monodoc/Monodoc.Ecma/EcmaDesc.cs
mcs/class/monodoc/Resources/mdoc-html-utils.xsl
mcs/class/monodoc/Test/Monodoc.Ecma/EcmaUrlTests.cs
mcs/tools/mdoc/Makefile
mcs/tools/mdoc/Mono.Documentation/monodocer.cs
mcs/tools/mdoc/Test/DocTest-addNonGeneric.cs [new file with mode: 0644]
mcs/tools/mdoc/mdoc.csproj

index 3d1e8c92c3fc3942526ca03a2b786af7f4440e2a..ccf4b4bb12d91b9720c874de7062d13928296514 100644 (file)
@@ -234,7 +234,9 @@ namespace Monodoc.Ecma
 
                        sb.Append ('.');
                        sb.Append (TypeName);
-                       if (GenericTypeArguments != null) {
+                       if (GenericTypeArguments != null && GenericTypeArgumentsIsNumeric) {
+                               sb.AppendFormat ("`{0}", GenericTypeArgumentsCount);
+                       } else if (GenericTypeArguments != null) {
                                sb.Append ('<');
                                int i=0;
                                foreach (var t in GenericTypeArguments) {
index 2c340f75074d1882105ca342d3543d4da67e2ed0..43983af55cf6eb58a3ceb2f9e59031d6e2338498 100644 (file)
                        <xsl:with-param name="child-id" select="concat ($linkid, ':Related:')" />
                        <xsl:with-param name="content">
                          <div class="related">
+                               <xsl:call-template name="CreateRelatedSection">
+                                 <xsl:with-param name="section" select="'Platform Docs'" />
+                                 <xsl:with-param name="type" select="'PlatformDocAPI'" />
+                               </xsl:call-template>
                                <xsl:call-template name="CreateRelatedSection">
                                  <xsl:with-param name="section" select="'Articles'" />
                                  <xsl:with-param name="type" select="'article'" />
index e6872f2ca5d902b74b5532e6e869126bf0069c2a..1c8d44311e616b1b250ec5688addd98e553d3809 100644 (file)
@@ -192,6 +192,17 @@ namespace MonoTests.Monodoc.Ecma
                        Assert.IsFalse (desc.GenericTypeArgumentsIsNumeric);
                }
 
+               [Test]
+               public void GenericTypeArgsNumericToStringTest ()
+               {
+                       string stringCref = "T:System.Collections.Generic.Dictionary`2";
+                       var desc = parser.Parse (stringCref);
+                       Assert.IsTrue (desc.GenericTypeArgumentsIsNumeric);
+                       Assert.AreEqual (2, desc.GenericTypeArguments.Count);
+                       string generatedEcmaCref = desc.ToEcmaCref ();
+                       Assert.AreEqual (stringCref, generatedEcmaCref);
+               }
+
                [Test]
                public void MetaEtcNodeTest ()
                {
index f9821f458e5b6325e3e2e8ac1fe7eb5e72d2ec14..ab95b1437c5686e1a8a21abee976d823aa435ba2 100644 (file)
@@ -91,6 +91,12 @@ cleanup:
        -rm -Rf Test/en.actual Test/html.actual
        -rm -f monodocer1.exe*
 
+Test/DocTest-addNonGeneric.dll:
+       $(CSCOMPILE) $(TEST_CSCFLAGS) -debug -unsafe -target:library -out:$@ Test/DocTest-addNonGeneric.cs
+
+Test/DocTest-addNonGeneric-v2.dll:
+       $(CSCOMPILE) $(TEST_CSCFLAGS) -debug -unsafe -target:library -out:$@ Test/DocTest-addNonGeneric.cs /define:V2
+
 Test/DocTest-DropNS-classic-secondary.dll:
        @echo $(value @)
        $(CSCOMPILE) $(TEST_CSCFLAGS) -debug -unsafe -target:library -out:$@ Test/DocTest-DropNS-classic-secondary.cs
@@ -121,6 +127,19 @@ Test/DocTest.dll-v2:
        -rm -f Test/DocTest.dll
        $(MAKE) TEST_CSCFLAGS=$(TEST_CSCFLAGS) Test/DocTest.dll
 
+check-monodocer-addNonGeneric: $(PROGRAM)
+       -rm -Rf Test/en.actual
+       # first, make a docset with the generic method
+       $(MAKE) Test/DocTest-addNonGeneric.dll
+       $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-addNonGeneric.dll
+
+       # now add a non-generic version of the method and update several times
+       $(MAKE) Test/DocTest-addNonGeneric-v2.dll
+       $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-addNonGeneric-v2.dll
+       $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-addNonGeneric-v2.dll
+       $(MONO) $(PROGRAM) update --exceptions=all -o Test/en.actual Test/DocTest-addNonGeneric-v2.dll
+       diff --exclude=.svn -rup Test/en.expected-addNonGeneric Test/en.actual
+
 check-monodocer-dropns-classic: $(PROGRAM)
        # tests the simplest --dropns case, a single class where the root namespace was dropped.
        -rm -Rf Test/en.actual
@@ -321,4 +340,6 @@ check-doc-tools-update: check-monodocer-since-update \
        check-mdoc-export-msxdoc-update \
        check-mdoc-validate-update 
 
+check: check-doc-tools \
+       check-doc-tools-update
 
index 842a4ae439f36136fbb90c5e5942dcf8b5d56cbb..8cdf5e7e519470d8bab0ee646a7c8b18984068b4 100644 (file)
@@ -3230,16 +3230,21 @@ class DocumentationEnumerator {
                        if (mi is MethodDefinition) {
                                MethodDefinition mb = (MethodDefinition) mi;
                                pis = mb.Parameters;
-                               if (docTypeParams != null && mb.IsGenericMethod ()) {
+                               if (mb.IsGenericMethod ()) {
                                        IList<GenericParameter> args = mb.GenericParameters;
-                                       if (args.Count == docTypeParams.Length) {
-                                               typeParams = args.Select (p => p.Name).ToArray ();
-                                       }
+                                       typeParams = args.Select (p => p.Name).ToArray ();
                                }
                        }
                        else if (mi is PropertyDefinition)
                                pis = ((PropertyDefinition)mi).Parameters;
-                       
+                               
+                       // check type parameters
+                       int methodTcount = member.TypeParameters == null ? 0 : member.TypeParameters.Count;
+                       int reflectionTcount = typeParams == null ? 0 : typeParams.Length;
+                       if (methodTcount != reflectionTcount) 
+                               continue;
+
+                       // check member parameters
                        int mcount = member.Parameters == null ? 0 : member.Parameters.Count;
                        int pcount = pis == null ? 0 : pis.Count;
                        if (mcount != pcount)
@@ -3793,6 +3798,7 @@ class DocumentationMember {
        public StringToStringMap MemberSignatures = new StringToStringMap ();
        public string ReturnType;
        public StringList Parameters;
+       public StringList TypeParameters;
        public string MemberName;
        public string MemberType;
 
@@ -3802,6 +3808,7 @@ class DocumentationMember {
                int depth = reader.Depth;
                bool go = true;
                StringList p = new StringList ();
+               StringList tp = new StringList ();
                do {
                        if (reader.NodeType != XmlNodeType.Element)
                                continue;
@@ -3829,6 +3836,10 @@ class DocumentationMember {
                                        if (reader.Depth == depth + 2 && shouldUse)
                                                p.Add (reader.GetAttribute ("Type"));
                                        break;
+                               case "TypeParameter":
+                                       if (reader.Depth == depth + 2 && shouldUse)
+                                               tp.Add (reader.GetAttribute ("Name"));
+                                       break;
                                case "Docs":
                                        if (reader.Depth == depth + 1)
                                                go = false;
@@ -3838,6 +3849,11 @@ class DocumentationMember {
                if (p.Count > 0) {
                        Parameters = p;
                }
+               if (tp.Count > 0) {
+                       TypeParameters = tp;
+               } else {
+                       DiscernTypeParameters ();
+               }
        }
 
        public DocumentationMember (XmlNode node)
@@ -3861,6 +3877,27 @@ class DocumentationMember {
                        for (int i = 0; i < p.Count; ++i)
                                Parameters.Add (p [i].Attributes ["Type"].Value);
                }
+               XmlNodeList tp = node.SelectNodes ("TypeParameters/TypeParameter[not(@apistyle) or @apistyle='classic']");
+               if (tp.Count > 0) {
+                       TypeParameters = new StringList (tp.Count);
+                       for (int i = 0; i < tp.Count; ++i)
+                               TypeParameters.Add (tp [i].Attributes ["Name"].Value);
+               }
+               else {
+                       DiscernTypeParameters ();
+               }
+       }
+
+       void DiscernTypeParameters ()
+       {
+               // see if we can discern the param list from the name
+               if (MemberName.Contains ("<") && MemberName.EndsWith (">")) {
+                       var starti = MemberName.IndexOf ("<") + 1;
+                       var endi = MemberName.LastIndexOf (">");
+                       var paramlist = MemberName.Substring (starti, endi - starti);
+                       var tparams = paramlist.Split (new char[] {','}, StringSplitOptions.RemoveEmptyEntries);
+                       TypeParameters = new StringList (tparams);
+               }
        }
 }
 
diff --git a/mcs/tools/mdoc/Test/DocTest-addNonGeneric.cs b/mcs/tools/mdoc/Test/DocTest-addNonGeneric.cs
new file mode 100644 (file)
index 0000000..60bde6e
--- /dev/null
@@ -0,0 +1,9 @@
+namespace MyNamespace {
+       public class MyClass {
+               public string SomeMethod<T>() { return string.Empty; }
+
+               #if V2
+               public string SomeMethod() { return string.Empty; }
+               #endif
+       }
+}
index 3394c9b2429b012bdd9a3b9b66cca728a14d09d5..7032bddcfb09e5bebb2606b12286f701baa51dea 100644 (file)
@@ -9,13 +9,14 @@
     <OutputType>Exe</OutputType>
     <RootNamespace>mdoc</RootNamespace>
     <AssemblyName>mdoc</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
     <DebugSymbols>True</DebugSymbols>
     <DebugType>full</DebugType>
     <Optimize>False</Optimize>
     <OutputPath>bin\Debug</OutputPath>
-    <DefineConstants>DEBUG;NET_4_0</DefineConstants>
+    <DefineConstants>DEBUG;NET_4_5</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <PlatformTarget>x86</PlatformTarget>
@@ -38,7 +39,7 @@
     <Reference Include="System.Xml" />
     <Reference Include="Mono.Cecil, Version=0.9.5.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
     <Reference Include="monodoc">
-      <HintPath>..\..\class\lib\net_4_0\monodoc.dll</HintPath>
+      <HintPath>..\..\class\lib\net_4_5\monodoc.dll</HintPath>
     </Reference>
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />