List Info

Thread: Generics Support for monodoc/tools




Generics Support for monodoc/tools
user name
2006-10-01 00:37:06
At the URL below is a patch to monodoc/tools to add support
for Generics
to monodocer.exe and monodocs2html.exe.  (Next stop: adding
support for
Generics to the documentation browser.)

The patch is available at:

        http://balthasar.jprl.com/~jon/tmp/monodoc-tools.patch

The monodocer.cs patch is fairly straightforward in concept,
if not in
implementation: Don't use Type.FullName, *ever*, as
Type.FullName is
generally not what you want.  It also leads to
NullReferenceExceptions
when parsing generic classes (e.g. `class Foo<T> {}').

Monodocer.exe now generates Namespace/Typename`NumArgs.xml
files for all
generic types, e.g. Mono.DocTest.Generic/MyList`2.xml. 
Because the
filenames for generic types will never match the C# typename
(MyList<A,B>), I've added a new File attribute into
index.xml.  (If you
don't like this, it should be possible to get the
"escaped" MyList`2
form from the MyList<A,B> form, but this is easiest.)

XML generated is in the same spirit as the XML Documentation
from
ECMA-335 3rd edition CLILibraryTypes.xml.  So generic
members have <...>
in the method name, e.g.

        <Member
MemberName="SomeMethod&lt;A,B&gt;">...&
lt;/Member>

As an "extension" to CLILibraryTypes.xml,
<typeparam/> elements are
inserted for each type parameter.  This is in keeping with
ECMA-334 3rd
edition, which suggests this tag for documenting type
parameters.  (Not
sure why CLILibraryTypes.xml didn't use it.)

The one breaking change to monodocer.exe is that '+' is no
longer used
for nested types, but '.' is used instead.  That is:

        public class Outer { public class Inner {}}

generates the file Outer.Inner.xml, while as before it would
generate
Outer+Inner.xml.  This change is necessary for
monodocs2html.exe, as
there is no way from a <see
cref="T:Namespace.Outer.Inner" /> reference
to tell which of those strings is the namespace, the outer
class, and
the inner class (at least, no easy way that I can see), so
removing the
'+' makes monodocs2html.exe easier to implement.

The monodocs2html.exe changes include the changes I
previously sent to
this mailing list, and includes an overhaul for supporting
generic types
and members.  It also follows some of the conventions used
on MSDN, so
"Class" follows classes, "Method"
follows methods, "Generic" is inserted
for generic types and methods, etc.

(It also is ugly-as-sin, containing joyfully recursive XSLT
calls to
convert "Foo<A,B>.Nested<C>" into
"Foo`2.Nested`1" constructs.  Lots of
fun.  Really.  Stop looking at me like that!)

I've also added unit tests to test both monodocer.exe &
monodocs2html.exe, and has the added benefit that you can
see what the
output from these tools looks like without needing to run it
first.

Permission to commit? [0]

 - Jon

[0] No, I don't mean permission to commit me to an asylum
for all those
recursive XSLT templates!  Recursion is fun!

_______________________________________________
Mono-docs-list maillist  -  Mono-docs-listlists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-docs-list
Generics Support for monodoc/tools
user name
2006-10-01 20:10:29
On Sat, 2006-09-30 at 20:37 -0400, Jonathan Pryor wrote:
> At the URL below is a patch to monodoc/tools to add
support for Generics
> to monodocer.exe and monodocs2html.exe.  (Next stop:
adding support for
> Generics to the documentation browser.)
> 
> The patch is available at:
> 
>         http://balthasar.jprl.com/~jon/tmp/monodoc-tools.patch

The above patch has been updated to remove the renaming
requirement (so
'+' is still used to separate nested types) and to fix an
issue with
generating `cref' declarations within HTML files.

I'd attach it, but it's a huge patch and I'll get another
email saying
"this message is too big and awaits moderator
approval," so please see
the above URL.

Thanks,
 - Jon


_______________________________________________
Mono-docs-list maillist  -  Mono-docs-listlists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-docs-list
Generics Support for monodoc/tools
user name
2006-10-03 11:59:25
Jonathan Pryor wrote:
>> At the URL below is a patch to monodoc/tools to add
support for Generics
>> to monodocer.exe and monodocs2html.exe.  (Next
stop: adding support for
>> Generics to the documentation browser.)

Hey,

Comments for the monodocer part of the patch:

After running it on some of my docs, I get these unexpected
changes:

-       
<ReturnType>SemWeb.N3Writer+Formats</ReturnType>
+       
<ReturnType>SemWeb.N3Writer.Formats</ReturnType>

(I'm not necessarily opposed to such a change, but I thought
that was
part of what was undone about "+" vs
".".)

- <Parameter Name="prefix"
Type="System.String&amp;"
RefType="out" />
+ <Parameter Name="prefix"
Type="System.String&amp;"
RefType="out">
+  <Attributes>
+   <Attribute>
+   
<AttributeName>System.Runtime.InteropServices.Out</
AttributeName>
+   </Attribute>
+  </Attributes>
+ </Parameter>

Is "out" exposed differently through reflection in
2.0?  I think we
should suppress this attribute, since it duplicates RefType.

Also (but this is related to the +/. thing), during an
update the
index.xml file was updated by adding entries like:

  <Type Name="Sparql.QueryType"
File="Sparql+QueryType" />

but without removing the old entry with the "+" in
the name.

Lastly, the File attribute wasn't added to any existing
entries in
index.xml when doing a doc update.

Looking forward to all the updates.

-- 
- Joshua Tauberer

http://razor.occams.info

"Strike up the klezmer and start acting like a man.
You're
about to have a truth-mitzvah."  -- The Colbert Report
_______________________________________________
Mono-docs-list maillist  -  Mono-docs-listlists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-docs-list
Generics Support for monodoc/tools
user name
2006-10-04 01:03:02
On Tue, 2006-10-03 at 07:59 -0400, Joshua Tauberer wrote:
> Jonathan Pryor wrote:
> >> At the URL below is a patch to monodoc/tools
to add support for Generics
> >> to monodocer.exe and monodocs2html.exe.  (Next
stop: adding support for
> >> Generics to the documentation browser.)

Looks like I should have tried to get monodoc/engine
finished before
sending this patch, as it requires using '+' instead of '.'
to separate
nested types.  (Thinking about it, there's no other way to
determine the
namespace, so Some.Namespace.OuterType.InnterType becomes
very ambiguous
to process, e.g. for namespace determination, as the
`monodoc' browser
does.)

Fortunately, I've have a monodoc/engine patch (which needs
to be cleaned
up).

Unfortunately, this changes things around for
monodocs2html.exe.

<Sigh.>

> Comments for the monodocer part of the patch:
> 
> After running it on some of my docs, I get these
unexpected changes:
> 
> -       
<ReturnType>SemWeb.N3Writer+Formats</ReturnType>
> +       
<ReturnType>SemWeb.N3Writer.Formats</ReturnType>
> 
> (I'm not necessarily opposed to such a change, but I
thought that was
> part of what was undone about "+" vs
".".)

The original reason for the "+" -> 
"." change was for C# syntax use --
the <XxxSignature Language="C#" ...> should
be in C#, so it should use
'.' to separate outer/inner types, but '+' was used instead,
so I
changed this.

Obviously, that was a bad change.

> - <Parameter Name="prefix"
Type="System.String&amp;"
RefType="out" />
> + <Parameter Name="prefix"
Type="System.String&amp;"
RefType="out">
> +  <Attributes>
> +   <Attribute>
> +   
<AttributeName>System.Runtime.InteropServices.Out</
AttributeName>
> +   </Attribute>
> +  </Attributes>
> + </Parameter>
> 
> Is "out" exposed differently through
reflection in 2.0?  I think we
> should suppress this attribute, since it duplicates
RefType.

.NET 2.0 "synthesizes" non-custom attributes so
that you can use
Reflection to retrieve the custom attributes.  Very useful
for getting
DllImportAttribute information at runtime.

However, it looks like I should keep this attribute from
being
displayed.

> Also (but this is related to the +/. thing), during an
update the
> index.xml file was updated by adding entries like:
> 
>   <Type Name="Sparql.QueryType"
File="Sparql+QueryType" />
> 
> but without removing the old entry with the
"+" in the name.

This won't be an issue in the future, since I'll have to
revert to the
previous syntax anyway (discussed above).

> Lastly, the File attribute wasn't added to any existing
entries in
> index.xml when doing a doc update.

IIRC, that's because the File attribute is only generated
when the
index.xml file is being created, not during an update (if
the filename
doesn't change).  This shouldn't be an issue, as the monodoc
code checks
for filenames matching both the Name and File
attributes, but it's
possible I'm not fully consistent here.

 - Jon


_______________________________________________
Mono-docs-list maillist  -  Mono-docs-listlists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-docs-list
Generics Support for monodoc/tools
user name
2006-10-04 12:55:18
On Tue, 2006-10-03 at 21:03 -0400, Jonathan Pryor wrote:
> Looks like I should have tried to get monodoc/engine
finished before
> sending this patch, as it requires using '+' instead of
'.' to separate
> nested types.  (Thinking about it, there's no other way
to determine the
> namespace, so Some.Namespace.OuterType.InnterType
becomes very ambiguous
> to process, e.g. for namespace determination, as the
`monodoc' browser
> does.)

Attached are patches to monodocer.cs (replaces previous
patch) and to
monodoc/engine.  The monodocs2html patch is not currently
included (I'm
still working on it.

Please review.

Question: does anything need to be done for the Compiled
documentation
case?  It currently works for uncompiled docs, but I haven't
tried with
compiled docs yet.

Thanks,

 - Jon

_______________________________________________
Mono-docs-list maillist  -  Mono-docs-listlists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-docs-list
Generics Support for monodoc/tools
user name
2006-10-05 12:23:17
On Wed, 2006-10-04 at 08:55 -0400, Jonathan Pryor wrote:
> On Tue, 2006-10-03 at 21:03 -0400, Jonathan Pryor
wrote:
> Attached are patches to monodocer.cs (replaces previous
patch) and to
> monodoc/engine.  The monodocs2html patch is not
currently included (I'm
> still working on it.

And now is attached the patches for monodocs2html.exe.

This does not take care of the File => CanonicalName change suggested
previously.

So...

Permission to commit these three patches (monodocs/engine,
monodocs/tools/monodocer, and monodocs/tools/monodocs2html)
after making
the attribute name change of File to CanonicalName?

(i.e. should I send out a patch with the CanonicalName
change, or should
I just commit after making that change?)

Once this is committed, I'll start looking into
<version/> support and
compiled ecma help docs.  The fact that this currently works
for
uncompiled help docs & monodocs2html gives me some
confidence that this
is functional code.

Thanks,
 - Jon

_______________________________________________
Mono-docs-list maillist  -  Mono-docs-listlists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-docs-list
Generics Support for monodoc/tools
user name
2006-10-05 12:51:58
I had to make a few changes to get monodocs2html to work.

In stylesheet.xsl, an instance of $type should have been, I
think,
$fullname, here:

<xsl:variable name="escaped-type">
      <xsl:call-template
name="GetEscapedTypeName">
           <xsl:with-param name="typename"
select="$fullname" />
      </xsl:call-template>
</xsl:variable>

In monodocs2html.cs, it didn't fall back to using Name if
File wasn't
found when getting a file name, so I added:
if (typefilebase == "") typefilebase = typename;

And there were other fallback issues...

Jonathan Pryor wrote:
> (i.e. should I send out a patch with the CanonicalName
change, or
> should I just commit after making that change?)

Feel free to commit, no need to send a patch for
CanonicalName.

> So perhaps we should split the difference, as it were:
rename the
> current Name attribute to DisplayName, and add a new
Name attribute
> which holds the generic name:
> 
> 	<Type Name="NonGeneric"
DisplayName="NonGeneric" />
> 	<Type Name="Generic`1"
DisplayName="Generic&lt;T&gt;" />

I like that a lot.  There's the added benefit that there
doesn't have to
be any falling back from File to Name in the tricky
filename-creation
and cref-comparison code, since Name was and will continue
to be the
attribute used for that.  Only the code that displays the
name of a type
will have to fall back to Name if DisplayName is not there,
which seems
a lot simpler.

-- 
- Joshua Tauberer

http://razor.occams.info

"Strike up the klezmer and start acting like a man.
You're
about to have a truth-mitzvah."  -- The Colbert Report


Jonathan Pryor wrote:
> On Wed, 2006-10-04 at 08:55 -0400, Jonathan Pryor
wrote:
>> On Tue, 2006-10-03 at 21:03 -0400, Jonathan Pryor
wrote: Attached
>> are patches to monodocer.cs (replaces previous
patch) and to 
>> monodoc/engine.  The monodocs2html patch is not
currently included
>> (I'm still working on it.
> 
> And now is attached the patches for monodocs2html.exe.
> 
> This does not take care of the File => CanonicalName change
> suggested previously.
> 
> So...
> 
> Permission to commit these three patches
(monodocs/engine, 
> monodocs/tools/monodocer, and
monodocs/tools/monodocs2html) after
> making the attribute name change of File to
CanonicalName?
> 
> (i.e. should I send out a patch with the CanonicalName
change, or
> should I just commit after making that change?)
> 
> Once this is committed, I'll start looking into
<version/> support
> and compiled ecma help docs.  The fact that this
currently works for 
> uncompiled help docs & monodocs2html gives me some
confidence that
> this is functional code.
> 
> Thanks, - Jon
> 


_______________________________________________
Mono-docs-list maillist  -  Mono-docs-listlists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-docs-list
[1-7]

about | contact  Other archives ( Real Estate discussion Medical topics )