monodocer System.ComponentModel patch
"Greg Steffensen" <[email protected]>
| Newsgroups | gmane.comp.gnome.mono.documentation |
|---|---|
| Message-ID | <[email protected]> |
I've patched monodocer to optionally look for member attributes that are instances of System.ComponentModel.DescriptionAttribute, and use the descriptions found there for the contents of the "summary" element instead of the default "To be added". If docs are being updated, and the old docs already have a summary, it gets overwritten (this could be changed if needed). This behaviour is disabled by default, and is turned on via a new "usedescriptions" flag to monodocer (this strikes me as not necessarily the best flag name... suggestions for a better one are welcome). This is my first contribution to mono, so feedback is greatly appreciated! Greg _______________________________________________ Mono-docs-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-docs-list
patchfile.txt
(text/plain, 1.7 KB)
Index: monodocer.cs
===================================================================
--- monodocer.cs (revision 58819)
+++ monodocer.cs (working copy)
@@ -9,6 +9,7 @@
using System.Xml;
using Mono.GetOptions;
+using System.ComponentModel;
[assembly: AssemblyTitle("Monodocer - The Mono Documentation Tool")]
[assembly: AssemblyCopyright("Copyright (c) 2004 Joshua Tauberer <[email protected]>\nreleased under the GPL.")]
@@ -23,6 +24,7 @@
static bool nooverrides = true, delete = false, ignoremembers = false;
static bool pretty = false;
+ static bool usedescriptions = false;
static int additions = 0, deletions = 0;
@@ -62,6 +64,10 @@
[Option("Indent the XML files nicely.")]
public bool pretty = false;
+
+ [Option("Use member descriptions provided via System.ComponentModel.DescriptionAttribute attributes")]
+ public bool usedescriptions = false;
+
}
@@ -83,6 +89,7 @@
ignoremembers = opts.ignoremembers;
name = opts.name;
pretty = opts.pretty;
+ usedescriptions = opts.usedescriptions;
try {
// PARSE BASIC OPTIONS AND LOAD THE ASSEMBLY TO DOCUMENT
@@ -757,6 +764,22 @@
string slashdocsig = MakeSlashDocMemberSig(mi);
MakeDocNode(me, paraminfo, returntype, returnisreturn, addremarks, slashdocsig);
+
+ // set the summary according to any DescriptionAttribute attrs,
+ // if the user asked us to
+ if (usedescriptions) {
+ object[] memberAttrs = mi.GetCustomAttributes(false);
+ XmlElement summary = (XmlElement)me.SelectSingleNode("Docs/summary");;
+ if (summary != null) {
+ foreach (object at in memberAttrs) {
+ if (at is DescriptionAttribute) {
+ string desc = ((DescriptionAttribute)at).Description;
+ summary.InnerText = desc;
+ }
+ }
+ }
+ }
+
}