Skip to content
This repository has been archived by the owner on Apr 30, 2020. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit 'Geaz' Gazic committed Aug 15, 2016
2 parents 15fbea1 + cacbf93 commit e38abb3
Show file tree
Hide file tree
Showing 14 changed files with 130 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/Core/SharpDox.Core/Config/CoreConfigSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public SDPath OutputPath
[Name(typeof(CoreStrings), "DocLanguage")]
public string DocLanguage
{
get { return _docLanguage; }
get { return string.IsNullOrEmpty(_docLanguage) ? "en" : _docLanguage; }
set
{
if (_docLanguage != value)
Expand Down
4 changes: 2 additions & 2 deletions src/Core/SharpDox.Model/Documentation/Token/SDTokenList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class SDTokenList : List<SDToken>
break;
}
}
return text;
return text.Trim();
}

public SDTemplate ToMarkdown(Dictionary<string, string> tokens)
Expand Down Expand Up @@ -59,7 +59,7 @@ public SDTemplate ToMarkdown(Dictionary<string, string> tokens)
break;
}
}
return new SDTemplate(text, tokens);
return new SDTemplate(text.Trim(), tokens);
}
}
}
50 changes: 49 additions & 1 deletion src/Core/SharpDox.Model/Repository/SDRegion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,43 @@ public class SDRegion

/// <default>
/// <summary>
/// Gets or sets the file within the region is defined.
/// Gets or sets the start line of the region.
/// </summary>
/// </default>
/// <de>
/// <summary>
/// Setzt oder liefert die Startzeile der Region.
/// </summary>
/// </de>
public int StartLine { get; set; }

/// <default>
/// <summary>
/// Gets or sets the end line of the region.
/// </summary>
/// </default>
/// <de>
/// <summary>
/// Setzt oder liefert die Endzeile der Region.
/// </summary>
/// </de>
public int EndLine { get; set; }

/// <default>
/// <summary>
/// Gets or sets the file path within the region is defined.
/// </summary>
/// </default>
/// <de>
/// <summary>
/// Setzt oder liefert den Pfad der Datei in der die Region definiert ist.
/// </summary>
/// </de>
public string FilePath { get; set; }

/// <default>
/// <summary>
/// Gets or sets the file name within the region is defined.
/// </summary>
/// </default>
/// <de>
Expand All @@ -50,5 +86,17 @@ public class SDRegion
/// </summary>
/// </de>
public string Filename { get; set; }

/// <default>
/// <summary>
/// Gets or sets the content of the file.
/// </summary>
/// </default>
/// <de>
/// <summary>
/// Setzt oder liefert den Inhalt der Datei.
/// </summary>
/// </de>
public string Content { get; set; }
}
}
8 changes: 4 additions & 4 deletions src/Core/SharpDox.Sdk/Config/Attributes/NameAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ namespace SharpDox.Sdk.Config.Attributes
/// [Name(typeof(CoreStrings), "ProjectName")]
/// public string ProjectName
/// {
/// get { [...] }
/// set { [...] }
/// get { /* ... */ }
/// set { /* ... */ }
/// }
/// </code>
/// </example>
Expand All @@ -31,8 +31,8 @@ namespace SharpDox.Sdk.Config.Attributes
/// [Name(typeof(CoreStrings), "ProjectName")]
/// public string ProjectName
/// {
/// get { [...] }
/// set { [...] }
/// get { /* ... */ }
/// set { /* ... */ }
/// }
/// </code>
/// </example>
Expand Down
2 changes: 1 addition & 1 deletion src/Core/SharpDox.Sdk/SDPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void UpdatePath(string fullPath, string basePath)

public static implicit operator string (SDPath path)
{
return path != null ? path.ResolvePath() : null;
return path?.ResolvePath();
}

public static implicit operator SDPath (string fullPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
using System.Linq;
using System.Xml.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.CodeAnalysis.Options;
using SharpDox.Model.Documentation;
using SharpDox.Model.Documentation.Token;
using SharpDox.Model.Repository;
Expand Down Expand Up @@ -107,7 +111,7 @@ private SDTokenList ParseContentTokens(XElement xmlElement, bool multilang)
content.Add(new SDToken
{
Role = SDTokenRole.Text,
Text = element.ToString().Trim()
Text = element.ToString()
});
}

Expand All @@ -128,7 +132,9 @@ private SDTokenList ParseContentTokens(XElement xmlElement, bool multilang)
content.Add(new SDToken { Role = SDTokenRole.ParamRef, Text = nodeElement.Attribute("name")?.Value });
break;
case "code":
content.Add(new SDCodeToken { Text = nodeElement.Value, IsInline = false });
var workspace = MSBuildWorkspace.Create();
var formattedResult = Formatter.Format(CSharpSyntaxTree.ParseText(nodeElement.Value, CSharpParseOptions.Default).GetRoot(), workspace);
content.Add(new SDCodeToken { Text = formattedResult.ToString(), IsInline = false });
break;
case "c":
content.Add(new SDCodeToken { Text = nodeElement.Value, IsInline = true });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System.IO;
using Microsoft.CodeAnalysis;
using SharpDox.Model.Repository;
using SharpDox.Model.Repository.Members;
Expand Down Expand Up @@ -32,12 +33,22 @@ internal void ParseEvents(SDType sdType, INamedTypeSymbol typeSymbol)

private SDEvent GetParsedEvent(IEventSymbol eve)
{
var syntaxReference = eve.DeclaringSyntaxReferences.Any() ? eve.DeclaringSyntaxReferences.Single() : null;
var sdEvent = new SDEvent(eve.GetIdentifier())
{
Name = eve.Name,
DeclaringType = _typeRefParser.GetParsedTypeReference(eve.ContainingType),
Accessibility = eve.DeclaredAccessibility.ToString().ToLower(),
Documentations = DocumentationParser.ParseDocumentation(eve)
Documentations = DocumentationParser.ParseDocumentation(eve),
Region = syntaxReference != null ? new SDRegion
{
Start = syntaxReference.Span.Start,
StartLine = syntaxReference.SyntaxTree.GetLineSpan(syntaxReference.Span).StartLinePosition.Line + 1,
EndLine = syntaxReference.SyntaxTree.GetLineSpan(syntaxReference.Span).EndLinePosition.Line + 1,
End = syntaxReference.Span.End,
FilePath = syntaxReference.SyntaxTree.FilePath,
Filename = Path.GetFileName(syntaxReference.SyntaxTree.FilePath)
} : null
};

ParserOptions.SDRepository.AddMember(sdEvent);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis;
using SharpDox.Model.Repository;
using SharpDox.Model.Repository.Members;
Expand Down Expand Up @@ -32,6 +33,7 @@ internal void ParseFields(SDType sdType, INamedTypeSymbol typeSymbol)

private SDField GetParsedField(IFieldSymbol field)
{
var syntaxReference = field.DeclaringSyntaxReferences.Any() ? field.DeclaringSyntaxReferences.Single() : null;
var sdField = new SDField(field.GetIdentifier())
{
Name = field.Name,
Expand All @@ -41,7 +43,16 @@ private SDField GetParsedField(IFieldSymbol field)
ConstantValue = field.ConstantValue != null ? field.ConstantValue.ToString() : string.Empty,
IsConst = field.IsConst,
IsReadonly = field.IsReadOnly,
Documentations = DocumentationParser.ParseDocumentation(field)
Documentations = DocumentationParser.ParseDocumentation(field),
Region = syntaxReference != null ? new SDRegion
{
Start = syntaxReference.Span.Start,
End = syntaxReference.Span.End,
StartLine = syntaxReference.SyntaxTree.GetLineSpan(syntaxReference.Span).StartLinePosition.Line + 1,
EndLine = syntaxReference.SyntaxTree.GetLineSpan(syntaxReference.Span).EndLinePosition.Line + 1,
FilePath = syntaxReference.SyntaxTree.FilePath,
Filename = Path.GetFileName(syntaxReference.SyntaxTree.FilePath)
} : null
};

ParserOptions.SDRepository.AddMember(sdField);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal void ParseMethodCalls()
foreach (var sdMethod in sdType.Methods)
{
HandleOnItemParseStart(sdMethod.Name);
var fileId = ParserOptions.CodeSolution.GetDocumentIdsWithFilePath(sdMethod.Region.Filename).Single();
var fileId = ParserOptions.CodeSolution.GetDocumentIdsWithFilePath(sdMethod.Region.FilePath).Single();
var file = ParserOptions.CodeSolution.GetDocument(fileId);
var syntaxTree = file.GetSyntaxTreeAsync().Result;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis;
using SharpDox.Model;
Expand Down Expand Up @@ -75,7 +76,10 @@ private SDMethod GetParsedMethod(IMethodSymbol method, bool isCtor)
{
Start = syntaxReference.Span.Start,
End = syntaxReference.Span.End,
Filename = syntaxReference.SyntaxTree.FilePath
StartLine = syntaxReference.SyntaxTree.GetLineSpan(syntaxReference.Span).StartLinePosition.Line + 1,
EndLine = syntaxReference.SyntaxTree.GetLineSpan(syntaxReference.Span).EndLinePosition.Line + 1,
FilePath = syntaxReference.SyntaxTree.FilePath,
Filename = Path.GetFileName(syntaxReference.SyntaxTree.FilePath)
} : null
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ internal void ParseProjectNamespacesRecursively(INamespaceSymbol namespaceSymbol

private SDNamespace GetParsedNamespace(INamespaceSymbol namespaceSymbol)
{
var descriptionFiles = _descriptionFiles.Where(d => Path.GetFileName(d).ToLower().Contains(namespaceSymbol.Name.ToLower() + ".sdnd"));
var descriptionFiles = _descriptionFiles.Where(d => Path.GetFileName(d).ToLower().Contains(namespaceSymbol.ToDisplayString().ToLower() + ".sdnd"));

var descriptions = new SDLanguageItemCollection<SDTemplate>();
foreach (var file in descriptionFiles)
{
if (!string.IsNullOrEmpty(namespaceSymbol.Name.Trim()))
if (!string.IsNullOrEmpty(namespaceSymbol.ToDisplayString().Trim()))
{
var splitted = Path.GetFileName(file).ToLower().Replace(namespaceSymbol.Name.ToLower(), " ").Split('.');
var splitted = Path.GetFileName(file).ToLower().Replace(namespaceSymbol.ToDisplayString().ToLower(), " ").Split('.');
if (splitted.Length > 0 && splitted[0].Length == 2 && CultureInfo.GetCultures(CultureTypes.AllCultures).Any(c => c.TwoLetterISOLanguageName == splitted[0]))
{
descriptions.Add(splitted[0], new SDTemplate(File.ReadAllText(file), ParserOptions.Tokens));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis;
using SharpDox.Model.Repository;
using SharpDox.Model.Repository.Members;
Expand Down Expand Up @@ -32,6 +33,7 @@ internal void ParseProperties(SDType sdType, INamedTypeSymbol typeSymbol)

private SDProperty GetParsedProperty(IPropertySymbol property)
{
var syntaxReference = property.DeclaringSyntaxReferences.Any() ? property.DeclaringSyntaxReferences.Single() : null;
var sdProperty = new SDProperty(property.GetIdentifier())
{
Name = property.Name,
Expand All @@ -43,7 +45,16 @@ private SDProperty GetParsedProperty(IPropertySymbol property)
IsAbstract = property.IsAbstract,
IsVirtual = property.IsVirtual,
IsOverride = property.IsOverride,
Documentations = DocumentationParser.ParseDocumentation(property)
Documentations = DocumentationParser.ParseDocumentation(property),
Region = syntaxReference != null ? new SDRegion
{
Start = syntaxReference.Span.Start,
End = syntaxReference.Span.End,
StartLine = syntaxReference.SyntaxTree.GetLineSpan(syntaxReference.Span).StartLinePosition.Line + 1,
EndLine = syntaxReference.SyntaxTree.GetLineSpan(syntaxReference.Span).EndLinePosition.Line + 1,
FilePath = syntaxReference.SyntaxTree.FilePath,
Filename = Path.GetFileName(syntaxReference.SyntaxTree.FilePath)
} : null
};

ParserOptions.SDRepository.AddMember(sdProperty);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis;
using SharpDox.Model.Repository;
Expand Down Expand Up @@ -49,6 +50,7 @@ private void ParseTheProjectType(INamedTypeSymbol typeSymbol)
else // already parsed as stranger
{
sdType.Namespace = ParserOptions.SDRepository.GetNamespaceByIdentifier(typeSymbol.ContainingNamespace.GetIdentifier());
sdType.Regions = GetRegions(typeSymbol);
sdType.IsProjectStranger = false;

if(!sdNamespace.Types.Contains(sdType)) sdNamespace.Types.Add(sdType);
Expand Down Expand Up @@ -126,18 +128,29 @@ private SDType CreateSDType(INamedTypeSymbol typeSymbol, SDNamespace sdNamespace
IsProjectStranger = false,
Kind = typeSymbol.TypeKind.ToString().ToLower()
};

sdType.Regions = GetRegions(typeSymbol);

return sdType;
}

private List<SDRegion> GetRegions(INamedTypeSymbol typeSymbol)
{
var regions = new List<SDRegion>();
foreach (var reference in typeSymbol.DeclaringSyntaxReferences.ToList())
{
var region = new SDRegion
{
Start = reference.Span.Start,
End = reference.Span.End,
Filename = reference.SyntaxTree.FilePath
StartLine = reference.SyntaxTree.GetLineSpan(reference.Span).StartLinePosition.Line + 1,
EndLine = reference.SyntaxTree.GetLineSpan(reference.Span).EndLinePosition.Line + 1,
FilePath = reference.SyntaxTree.FilePath,
Filename = Path.GetFileName(reference.SyntaxTree.FilePath),
Content = File.ReadAllText(reference.SyntaxTree.FilePath)
};
sdType.Regions.Add(region);
regions.Add(region);
}
return sdType;
return regions;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private void ResolveCall(SDNode call)
var calledType = _sdRepository.GetTypeByIdentifier(targetNode.CalledType.Identifier);
var callerType = _sdRepository.GetTypeByIdentifier(targetNode.CallerType.Identifier);

if (calledType != null && callerType != null && calledType.Identifier != callerType.Identifier)
if (calledType != null && callerType != null && calledType.Identifier != callerType.Identifier && !calledType.IsProjectStranger && !callerType.IsProjectStranger)
{
if (!calledType.IsProjectStranger && calledType.UsedBy.SingleOrDefault(u => u.Identifier == callerType.Identifier) == null)
calledType.UsedBy.Add(callerType);
Expand Down

0 comments on commit e38abb3

Please sign in to comment.