Author: joshua
Date: 2005-05-08 19:20:09 -0400 (Sun, 08 May 2005)
New Revision: 44227
Modified:
trunk/monodoc/tools/ChangeLog
trunk/monodoc/tools/monodocer.cs
Log:
2005-05-09 Joshua Tauberer <[EMAIL PROTECTED]>
* Thanks for pushing me to use a ChangeLog.
* Disallow documenting types in the root namespace (type.Namespace ==
null).
* When a <code> tag has a 'src' attribute, monodocer will replace
the contents of the element with the text in the indicated file.
the path is relative to the path given as the --path option.
* Properties that have different access modifiers on their accessors
are now given signatures that reflect that. (But Monodoc doesn't
recognize this properly. A format change is needed.)
Modified: trunk/monodoc/tools/ChangeLog
===================================================================
--- trunk/monodoc/tools/ChangeLog 2005-05-08 23:14:05 UTC (rev 44226)
+++ trunk/monodoc/tools/ChangeLog 2005-05-08 23:20:09 UTC (rev 44227)
@@ -1,3 +1,15 @@
+2005-05-09 Joshua Tauberer <[EMAIL PROTECTED]>
+
+ * Thanks for pushing me to use a ChangeLog.
+ * Disallow documenting types in the root namespace (type.Namespace ==
+ null).
+ * When a <code> tag has a 'src' attribute, monodocer will replace
+ the contents of the element with the text in the indicated file.
+ the path is relative to the path given as the --path option.
+ * Properties that have different access modifiers on their accessors
+ are now given signatures that reflect that. (But Monodoc doesn't
+ recognize this properly. A format change is needed.)
+
2005-01-29 Jonathan Pryor <[EMAIL PROTECTED]>
* ChangeLog: Added
Modified: trunk/monodoc/tools/monodocer.cs
===================================================================
--- trunk/monodoc/tools/monodocer.cs 2005-05-08 23:14:05 UTC (rev 44226)
+++ trunk/monodoc/tools/monodocer.cs 2005-05-08 23:20:09 UTC (rev 44227)
@@ -18,6 +18,7 @@
public class Stub {
+ static string srcPath;
static Assembly assembly;
static bool nooverrides = true, delete = false, ignoremembers = false;
@@ -72,6 +73,8 @@
if (opts.path == null)
throw new InvalidOperationException("The path
option is required.");
+
+ srcPath = opts.path;
if (n(opts.type) + n([EMAIL PROTECTED]) > 1)
throw new InvalidOperationException("You cannot
specify both 'type' and 'namespace'.");
@@ -182,6 +185,7 @@
public static void DoUpdateType(string basepath, string typename,
string dest) {
Type type = assembly.GetType(typename, false);
if (type == null) throw new InvalidOperationException("Type not
found: " + typename);
+ if (type.Namespace == null) throw new
InvalidOperationException("Types in the root namespace cannot be documented: "
+ typename);
string typename2 = type.FullName.Substring(type.Namespace == ""
? 0 : type.Namespace.Length+1);
XmlDocument basefile = new XmlDocument();
@@ -229,6 +233,7 @@
// Stub types not in the directory
foreach (Type type in assembly.GetTypes()) {
+ if (type.Namespace == null) continue;
if (type.Namespace != ns || seenTypes.ContainsKey(type))
continue;
@@ -268,6 +273,8 @@
Hashtable goodfiles = new Hashtable();
foreach (Type type in assembly.GetTypes()) {
+ if (type.Namespace == null) continue;
+
// Must get the A+B form of the type name.
string typename = GetTypeFileName(type);
@@ -415,6 +422,21 @@
additions++;
}
}
+
+ // Import code snippets from files
+ foreach (XmlNode code in basefile.GetElementsByTagName("code"))
{
+ if (!(code is XmlElement)) continue;
+ string file = ((XmlElement)code).GetAttribute("src");
+ if (file != "") {
+ try {
+ using (System.IO.StreamReader reader =
new System.IO.StreamReader(srcPath + "/" + file)) {
+ code.InnerText =
reader.ReadToEnd();
+ }
+ } catch (Exception e) {
+ Console.Error.WriteLine("Could not load
code file '" + srcPath + "/" + file + "': " + e.Message);
+ }
+ }
+ }
System.IO.TextWriter writer;
if (output == null)
@@ -1111,7 +1133,6 @@
StringBuilder sb = new StringBuilder ();
int i = 0;
- string modifier;
foreach (ParameterInfo parameter in pi) {
if (i != 0) sb.Append (", ");
if (parameter.ParameterType.IsByRef) {
@@ -1175,15 +1196,19 @@
static string MakePropertySignature (PropertyInfo property) {
- // pick an accessor
+ // Check accessibility of get and set, since they can be
different these days.
+ string get_visible = null, set_visible = null;
+ MethodBase get_method = property.GetGetMethod (true);
+ MethodBase set_method = property.GetSetMethod (true);
+ if (get_method != null) get_visible =
GetMethodVisibility(get_method);
+ if (set_method != null) set_visible =
GetMethodVisibility(set_method);
+ if (get_visible == null && set_visible == null) return null; //
neither are visible
+
+ // Pick an accessor to use for static/virtual/override/etc.
checks.
MethodBase method = property.GetSetMethod (true);
if (method == null)
method = property.GetGetMethod (true);
- string visibility = GetMethodVisibility(method);
- if (visibility == null)
- return null;
-
string modifiers = String.Empty;
if (method.IsStatic) modifiers += " static";
if (method.IsVirtual && !method.IsAbstract) {
@@ -1202,13 +1227,26 @@
string parameters = GetMethodParameters
(property.GetIndexParameters());
if (parameters != "") parameters = "[" + parameters + "]";
- string accessors = null;
- if (property.CanRead && property.CanWrite)
- accessors = "{ set; get; }";
- else if (property.CanRead)
- accessors = "{ get; }";
- else if (property.CanWrite)
- accessors = "{ set; }";
+ string visibility;
+ if (get_visible != null && (set_visible == null || (set_visible
!= null && get_visible == set_visible)))
+ visibility = get_visible;
+ else if (set_visible != null && get_visible == null)
+ visibility = set_visible;
+ else
+ visibility = "public"; // if they are different, but
both externally accessible, the greater access must be public, I think
+
+ string accessors = "{";
+ if (set_visible != null) {
+ if (set_visible != visibility)
+ accessors += " " + set_visible;
+ accessors += " set;";
+ }
+ if (get_visible != null) {
+ if (get_visible != visibility)
+ accessors += " " + get_visible;
+ accessors += " get;";
+ }
+ accessors += " }";
return String.Format ("{0}{1} {2} {3}{4} {5};",
visibility, modifiers,
type_name, name, parameters, accessors);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches