Permalink
Browse files

Got references working for everything again

  • Loading branch information...
1 parent 7afff2a commit ea6e6320f2ad3ad1c868de2c599310dcc2acdfb4 @jagregory committed Mar 31, 2009
@@ -8,9 +8,13 @@ namespace Docu.Documentation
{
public class Event : BaseDocumentationElement, IReferencable
{
- public Event(EventIdentifier identifier)
+ public DeclaredType Type { get; set; }
+
+ public Event(EventIdentifier identifier, DeclaredType type)
: base(identifier)
- {}
+ {
+ Type = type;
+ }
public string FullName
{
@@ -42,9 +46,9 @@ public void Resolve(IDictionary<Identifier, IReferencable> referencables)
ConvertToExternalReference();
}
- public static Event Unresolved(EventIdentifier eventIdentifier)
+ public static Event Unresolved(EventIdentifier eventIdentifier, DeclaredType type)
{
- return new Event(eventIdentifier) { IsResolved = false };
+ return new Event(eventIdentifier, type) { IsResolved = false };
}
}
}
@@ -8,9 +8,13 @@ namespace Docu.Documentation
{
public class Field : BaseDocumentationElement, IReferencable
{
- public Field(FieldIdentifier identifier)
+ public DeclaredType Type { get; set; }
+
+ public Field(FieldIdentifier identifier, DeclaredType type)
: base(identifier)
- {}
+ {
+ Type = type;
+ }
public string FullName
{
@@ -50,14 +54,14 @@ public void Resolve(IDictionary<Identifier, IReferencable> referencables)
ConvertToExternalReference();
}
- public static Field Unresolved(FieldIdentifier fieldIdentifier)
+ public static Field Unresolved(FieldIdentifier fieldIdentifier, DeclaredType type)
{
- return new Field(fieldIdentifier) { IsResolved = false };
+ return new Field(fieldIdentifier, type) { IsResolved = false };
}
- public static Field Unresolved(FieldIdentifier fieldIdentifier, IReferencable returnType)
+ public static Field Unresolved(FieldIdentifier fieldIdentifier, DeclaredType type, IReferencable returnType)
{
- return new Field(fieldIdentifier) { IsResolved = false, ReturnType = returnType };
+ return new Field(fieldIdentifier, type) { IsResolved = false, ReturnType = returnType };
}
}
}
@@ -21,7 +21,7 @@ public void Add(List<Namespace> namespaces, DocumentedEvent association)
var ns = FindNamespace(association, namespaces);
var type = FindType(ns, association);
- var doc = Event.Unresolved(Identifier.FromEvent(association.Event, association.TargetType));
+ var doc = Event.Unresolved(Identifier.FromEvent(association.Event, association.TargetType), type);
ParseSummary(association, doc);
ParseRemarks(association, doc);
@@ -24,7 +24,7 @@ public void Add(List<Namespace> namespaces, DocumentedField association)
association.Field.FieldType,
Namespace.Unresolved(
Identifier.FromNamespace(association.Field.FieldType.Namespace)));
- var doc = Field.Unresolved(Identifier.FromField(association.Field, association.TargetType), returnType);
+ var doc = Field.Unresolved(Identifier.FromField(association.Field, association.TargetType), type, returnType);
ParseSummary(association, doc);
ParseRemarks(association, doc);
@@ -21,12 +21,13 @@ public void Add(List<Namespace> namespaces, DocumentedMethod association)
var ns = FindNamespace(association, namespaces);
var type = FindType(ns, association);
- DeclaredType methodReturnType = DeclaredType.Unresolved(
+ var methodReturnType = DeclaredType.Unresolved(
Identifier.FromType(association.Method.ReturnType),
association.Method.ReturnType,
Namespace.Unresolved(Identifier.FromNamespace(association.Method.ReturnType.Namespace)));
- Method doc = Method.Unresolved(Identifier.FromMethod(association.Method, association.TargetType),
- association.Method, methodReturnType);
+ var doc = Method.Unresolved(
+ Identifier.FromMethod(association.Method, association.TargetType),
+ type, association.Method, methodReturnType);
ParseSummary(association, doc);
ParseRemarks(association, doc);
@@ -22,13 +22,12 @@ public void Add(List<Namespace> namespaces, DocumentedProperty association)
var ns = FindNamespace(association, namespaces);
var type = FindType(ns, association);
- DeclaredType propertyReturnType =
+ var propertyReturnType =
DeclaredType.Unresolved(Identifier.FromType(association.Property.PropertyType),
association.Property.PropertyType,
Namespace.Unresolved(
Identifier.FromNamespace(association.Property.PropertyType.Namespace)));
- Property doc = Property.Unresolved(Identifier.FromProperty(association.Property, association.TargetType),
- propertyReturnType);
+ var doc = Property.Unresolved(Identifier.FromProperty(association.Property, association.TargetType), type, propertyReturnType);
ParseSummary(association, doc);
ParseValue(association, doc);
@@ -12,9 +12,10 @@ public class Method : BaseDocumentationElement, IReferencable
private readonly IList<MethodParameter> parameters = new List<MethodParameter>();
private MethodInfo representedMethod;
- public Method(MethodIdentifier identifier)
+ public Method(MethodIdentifier identifier, DeclaredType type)
: base(identifier)
{
+ Type = type;
Returns = new Returns();
}
@@ -33,6 +34,7 @@ public bool IsStatic
get { return ((MethodIdentifier)identifier).IsStatic; }
}
+ public DeclaredType Type { get; set; }
public IReferencable ReturnType { get; set; }
public Returns Returns { get; set; }
@@ -85,16 +87,19 @@ internal void AddParameter(MethodParameter parameter)
parameters.Add(parameter);
}
- public static Method Unresolved(MethodIdentifier methodIdentifier)
+ public static Method Unresolved(MethodIdentifier methodIdentifier, DeclaredType type)
{
- return new Method(methodIdentifier) { IsResolved = false };
+ return new Method(methodIdentifier, type) { IsResolved = false };
}
- public static Method Unresolved(MethodIdentifier methodIdentifier, MethodInfo representedMethod,
- IReferencable returnType)
+ public static Method Unresolved(MethodIdentifier methodIdentifier, DeclaredType type, MethodInfo representedMethod, IReferencable returnType)
{
- return new Method(methodIdentifier)
- { IsResolved = false, representedMethod = representedMethod, ReturnType = returnType };
+ return new Method(methodIdentifier, type)
+ {
+ IsResolved = false,
+ representedMethod = representedMethod,
+ ReturnType = returnType
+ };
}
}
}
@@ -8,13 +8,15 @@ namespace Docu.Documentation
{
public class Property : BaseDocumentationElement, IReferencable
{
- public Property(PropertyIdentifier identifier)
+ public Property(PropertyIdentifier identifier, DeclaredType type)
: base(identifier)
{
+ Type = type;
HasGet = identifier.HasGet;
HasSet = identifier.HasSet;
}
+ public DeclaredType Type { get; set; }
public bool HasGet { get; private set; }
public bool HasSet { get; private set; }
@@ -56,14 +58,14 @@ public void Resolve(IDictionary<Identifier, IReferencable> referencables)
ConvertToExternalReference();
}
- public static Property Unresolved(PropertyIdentifier propertyIdentifier)
+ public static Property Unresolved(PropertyIdentifier propertyIdentifier, DeclaredType type)
{
- return new Property(propertyIdentifier) { IsResolved = false };
+ return new Property(propertyIdentifier, type) { IsResolved = false };
}
- public static Property Unresolved(PropertyIdentifier propertyIdentifier, IReferencable returnType)
+ public static Property Unresolved(PropertyIdentifier propertyIdentifier, DeclaredType type, IReferencable returnType)
{
- return new Property(propertyIdentifier) { IsResolved = false, ReturnType = returnType };
+ return new Property(propertyIdentifier, type) { IsResolved = false, ReturnType = returnType };
}
}
}
@@ -17,13 +17,37 @@ public IComment Parse(XmlNode content)
else if (referenceTarget is TypeIdentifier)
reference = DeclaredType.Unresolved((TypeIdentifier)referenceTarget, Namespace.Unresolved(referenceTarget.CloneAsNamespace()));
else if (referenceTarget is MethodIdentifier)
- reference = Method.Unresolved((MethodIdentifier)referenceTarget);
+ reference = Method.Unresolved(
+ (MethodIdentifier)referenceTarget,
+ DeclaredType.Unresolved(
+ referenceTarget.CloneAsType(),
+ Namespace.Unresolved(referenceTarget.CloneAsNamespace())
+ )
+ );
else if (referenceTarget is PropertyIdentifier)
- reference = Property.Unresolved((PropertyIdentifier)referenceTarget);
+ reference = Property.Unresolved(
+ (PropertyIdentifier)referenceTarget,
+ DeclaredType.Unresolved(
+ referenceTarget.CloneAsType(),
+ Namespace.Unresolved(referenceTarget.CloneAsNamespace())
+ )
+ );
else if (referenceTarget is EventIdentifier)
- reference = Event.Unresolved((EventIdentifier)referenceTarget);
+ reference = Event.Unresolved(
+ (EventIdentifier)referenceTarget,
+ DeclaredType.Unresolved(
+ referenceTarget.CloneAsType(),
+ Namespace.Unresolved(referenceTarget.CloneAsNamespace())
+ )
+ );
else if (referenceTarget is FieldIdentifier)
- reference = Field.Unresolved((FieldIdentifier)referenceTarget);
+ reference = Field.Unresolved(
+ (FieldIdentifier)referenceTarget,
+ DeclaredType.Unresolved(
+ referenceTarget.CloneAsType(),
+ Namespace.Unresolved(referenceTarget.CloneAsNamespace())
+ )
+ );
return new See(reference);
}
@@ -23,6 +23,10 @@ public HtmlOutputFormatter()
NamespaceUrlFormat = "{namespace}.htm";
TypeUrlFormat = "{type.namespace}/{type}.htm";
+ MethodUrlFormat = "{type.namespace}/{type}.htm#{method}";
+ PropertyUrlFormat = "{type.namespace}/{type}.htm#{property}";
+ FieldUrlFormat = "{type.namespace}/{type}.htm#{field}";
+ EventUrlFormat = "{type.namespace}/{type}.htm#{event}";
}
public string Format(IComment comment)
@@ -65,20 +69,7 @@ private string FormatInlineText(InlineText comment)
private string FormatSee(See block)
{
- string url = "";
-
- if (block.Reference is Namespace)
- url = Format(NamespaceUrlFormat,
- new Dictionary<string, string> { { "namespace", block.Reference.Name } });
- else if (block.Reference is DeclaredType)
- url = Format(TypeUrlFormat,
- new Dictionary<string, string>
- {
- { "type.namespace", ((DeclaredType)block.Reference).Namespace.Name },
- { "type", block.Reference.Name }
- });
-
- return "<a href=\"" + url + "\">" + block.Reference.Name + "</a>";
+ return FormatReferencable(block.Reference);
}
public string FormatReferencable(IReferencable reference)
@@ -87,14 +78,47 @@ public string FormatReferencable(IReferencable reference)
string name = reference.PrettyName;
if (reference is Namespace)
- url = Format(NamespaceUrlFormat, new Dictionary<string, string> { { "namespace", reference.Name } });
+ url = Format(NamespaceUrlFormat, new Replacement("namespace", reference.Name));
else if (reference is DeclaredType)
url = Format(TypeUrlFormat,
- new Dictionary<string, string>
- {
- { "type.namespace", ((DeclaredType)reference).Namespace.Name },
- { "type", reference.Name }
- });
+ new Replacement("type.namespace", ((DeclaredType)reference).Namespace.Name),
+ new Replacement("type", reference.Name));
+ else if (reference is Method)
+ {
+ var type = ((Method)reference).Type;
+
+ url = Format(MethodUrlFormat,
+ new Replacement("type.namespace", type.Namespace.Name),
+ new Replacement("type", type.Name),
+ new Replacement("method", reference.Name));
+ }
+ else if (reference is Property)
+ {
+ var type = ((Property)reference).Type;
+
+ url = Format(PropertyUrlFormat,
+ new Replacement("type.namespace", type.Namespace.Name),
+ new Replacement("type", type.Name),
+ new Replacement("property", reference.Name));
+ }
+ else if (reference is Field)
+ {
+ var type = ((Field)reference).Type;
+
+ url = Format(FieldUrlFormat,
+ new Replacement("type.namespace", type.Namespace.Name),
+ new Replacement("type", type.Name),
+ new Replacement("field", reference.Name));
+ }
+ else if (reference is Event)
+ {
+ var type = ((Event)reference).Type;
+
+ url = Format(EventUrlFormat,
+ new Replacement("type.namespace", type.Namespace.Name),
+ new Replacement("type", type.Name),
+ new Replacement("event", reference.Name));
+ }
if (reference.IsExternal)
return "<span title=\"" + reference.FullName + "\">" + Escape(reference.PrettyName) + "</span>";
@@ -114,17 +138,33 @@ private string FormatInlineCode(InlineCode block)
public string NamespaceUrlFormat { get; set; }
public string TypeUrlFormat { get; set; }
+ public string MethodUrlFormat { get; set; }
+ public string PropertyUrlFormat { get; set; }
+ public string FieldUrlFormat { get; set; }
+ public string EventUrlFormat { get; set; }
- private string Format(string pattern, IDictionary<string, string> pairs)
+ private string Format(string pattern, params Replacement[] replacements)
{
string output = pattern;
- foreach (var pair in pairs)
+ foreach (var replacement in replacements)
{
- output = output.Replace("{" + pair.Key + "}", pair.Value);
+ output = output.Replace("{" + replacement.Key + "}", replacement.Value);
}
return output;
}
+
+ private class Replacement
+ {
+ public string Key { get; private set; }
+ public string Value { get; private set; }
+
+ public Replacement(string key, string value)
+ {
+ Key = key;
+ Value = value;
+ }
+ }
}
}
@@ -8,6 +8,10 @@ public interface IOutputFormatter
{
string NamespaceUrlFormat { get; set; }
string TypeUrlFormat { get; set; }
+ string MethodUrlFormat { get; set; }
+ string PropertyUrlFormat { get; set; }
+ string FieldUrlFormat { get; set; }
+ string EventUrlFormat { get; set; }
string Format(IComment comment);
string FormatReferencable(IReferencable referencable);
string Escape(string value);
@@ -1,5 +1,10 @@
-# Formatter.NamespaceUrlFormat = "../{namespace}.htm";
+# // overrides for paths - this should be handled better
+# Formatter.NamespaceUrlFormat = "../{namespace}.htm";
# Formatter.TypeUrlFormat = "../{type.namespace}/{type}.htm";
+# Formatter.MethodUrlFormat = "../{type.namespace}/{type}.htm#{method}";
+# Formatter.PropertyUrlFormat = "../{type.namespace}/{type}.htm#{property}";
+# Formatter.FieldUrlFormat = "../{type.namespace}/{type}.htm#{field}";
+# Formatter.EventUrlFormat = "../{type.namespace}/{type}.htm#{event}";
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
@@ -1,3 +1,3 @@
-<blockquote class="value" if="content.Count > 0">
- <strong>Value: </strong>${WriteSummary(content)}
+<blockquote class="value" if="content.Children.Count() > 0">
+ <strong>Value: </strong>${Format(content)}
</blockquote>
Oops, something went wrong.

0 comments on commit ea6e632

Please sign in to comment.