Browse Source

Merge remote-tracking branch 'abpframework/dev' into docs

pull/3356/head
liangshiwei 7 years ago
parent
commit
6751bf0097
  1. 2
      docs/zh-Hans/UI/AspNetCore/Tag-Helpers/Tabs.md
  2. 43
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs
  3. 7
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs
  4. 47
      modules/docs/src/Volo.Docs.Web/Markdown/MarkdownDocumentToHtmlConverter.cs

2
docs/zh-Hans/UI/AspNetCore/Tag-Helpers/Tabs.md

@ -28,7 +28,7 @@
## Demo ## Demo
参阅[卡面demo页面](https://bootstrap-taghelpers.abp.io/Components/Cards)查看示例. 参阅[卡面demo页面](https://bootstrap-taghelpers.abp.io/Components/Tabs)查看示例.
## abp-tab Attributes ## abp-tab Attributes

43
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs

@ -57,9 +57,19 @@ namespace Volo.Abp.Cli.Commands
var uiFramework = GetUiFramework(commandLineArgs); var uiFramework = GetUiFramework(commandLineArgs);
WebClient client = new WebClient(); WebClient client = new WebClient();
string json = client.DownloadString(apiUrl); string json = "";
//var sr = File.OpenText("api-definition.json"); try
//var json = sr.ReadToEnd(); {
json = client.DownloadString(apiUrl);
}
catch (Exception ex)
{
throw new CliUsageException(
"Cannot connect to the host {" + apiUrl + "}! Check that the host is up and running." +
Environment.NewLine + Environment.NewLine +
GetUsageInfo()
);
}
Logger.LogInformation("Downloading api definition..."); Logger.LogInformation("Downloading api definition...");
Logger.LogInformation("Api Url: " + apiUrl); Logger.LogInformation("Api Url: " + apiUrl);
@ -107,7 +117,7 @@ namespace Volo.Abp.Cli.Commands
serviceFileText.AppendLine(""); serviceFileText.AppendLine("");
serviceFileText.AppendLine("@Injectable({providedIn: 'root'})"); serviceFileText.AppendLine("@Injectable({providedIn: 'root'})");
serviceFileText.AppendLine("export class [controllerName]Service {"); serviceFileText.AppendLine("export class [controllerName]Service {");
serviceFileText.AppendLine(" apiName = '"+ apiName + "';"); serviceFileText.AppendLine(" apiName = '" + apiName + "';");
serviceFileText.AppendLine(""); serviceFileText.AppendLine("");
serviceFileText.AppendLine(" constructor(private restService: RestService) {}"); serviceFileText.AppendLine(" constructor(private restService: RestService) {}");
serviceFileText.AppendLine(""); serviceFileText.AppendLine("");
@ -125,7 +135,7 @@ namespace Volo.Abp.Cli.Commands
actionName = (char.ToLower(actionName[0]) + actionName.Substring(1)).Replace("Async", "").Replace("Controller", ""); actionName = (char.ToLower(actionName[0]) + actionName.Substring(1)).Replace("Async", "").Replace("Controller", "");
var returnValueType = (string)action["returnValue"]["type"]; var returnValueType = (string)action["returnValue"]["type"];
var parameters = action["parameters"]; var parameters = action["parameters"];
var parametersText = new StringBuilder(); var parametersText = new StringBuilder();
@ -140,7 +150,7 @@ namespace Volo.Abp.Cli.Commands
var bindingSourceId = (string)parameter["bindingSourceId"]; var bindingSourceId = (string)parameter["bindingSourceId"];
bindingSourceId = char.ToLower(bindingSourceId[0]) + bindingSourceId.Substring(1); bindingSourceId = char.ToLower(bindingSourceId[0]) + bindingSourceId.Substring(1);
var name = (string)parameter["name"]; var name = (string)parameter["name"];
var typeSimple = (string)parameter["typeSimple"]; var typeSimple = (string)parameter["typeSimple"];
var typeArray = ((string)parameter["type"]).Split("."); var typeArray = ((string)parameter["type"]).Split(".");
var type = (typeArray[typeArray.Length - 1]).TrimEnd('>'); var type = (typeArray[typeArray.Length - 1]).TrimEnd('>');
@ -201,7 +211,8 @@ namespace Volo.Abp.Cli.Commands
{ {
secondTypeList.Add(type); secondTypeList.Add(type);
} }
else { else
{
firstTypeList.Add(type); firstTypeList.Add(type);
} }
break; break;
@ -217,7 +228,7 @@ namespace Volo.Abp.Cli.Commands
var parameterItemModelPath = $"src/app/{rootPath}/shared/models/{parameterItemModelName}"; var parameterItemModelPath = $"src/app/{rootPath}/shared/models/{parameterItemModelName}";
if (parameterItem.BindingSourceId == "body" && !File.Exists(parameterItemModelPath)) if (parameterItem.BindingSourceId == "body" && !File.Exists(parameterItemModelPath))
{ {
parameterItem.Type = "any"; parameterItem.Type = "any";
} }
parametersIndex++; parametersIndex++;
@ -248,7 +259,7 @@ namespace Volo.Abp.Cli.Commands
var firstType = firstTypeArray[firstTypeArray.Length - 1]; var firstType = firstTypeArray[firstTypeArray.Length - 1];
var secondTypeArray = returnValueType.Split("<")[1].Split("."); var secondTypeArray = returnValueType.Split("<")[1].Split(".");
var secondType = secondTypeArray[secondTypeArray.Length - 1].TrimEnd('>'); var secondType = secondTypeArray[secondTypeArray.Length - 1].TrimEnd('>');
var secondTypeModelName = secondType.PascalToKebabCase() + ".ts"; var secondTypeModelName = secondType.PascalToKebabCase() + ".ts";
var secondTypeModelPath = $"src/app/{rootPath}/shared/models/{secondTypeModelName}"; var secondTypeModelPath = $"src/app/{rootPath}/shared/models/{secondTypeModelName}";
@ -405,7 +416,7 @@ namespace Volo.Abp.Cli.Commands
} }
private static string CreateType(JObject data, string returnValueType, string rootPath, List<string> modelIndexList) private static string CreateType(JObject data, string returnValueType, string rootPath, List<string> modelIndexList)
{ {
var type = data["types"][returnValueType]; var type = data["types"][returnValueType];
if (type == null) if (type == null)
@ -435,9 +446,9 @@ namespace Volo.Abp.Cli.Commands
} }
var typeModelName = typeName.Replace("<", "").Replace(">", "").Replace("?","").PascalToKebabCase() + ".ts"; var typeModelName = typeName.Replace("<", "").Replace(">", "").Replace("?", "").PascalToKebabCase() + ".ts";
var path = $"src/app/{rootPath}/shared/models/{typeModelName}"; var path = $"src/app/{rootPath}/shared/models/{typeModelName}";
var modelFileText = new StringBuilder(); var modelFileText = new StringBuilder();
@ -474,7 +485,7 @@ namespace Volo.Abp.Cli.Commands
if (!string.IsNullOrWhiteSpace(modelIndex)) if (!string.IsNullOrWhiteSpace(modelIndex))
{ {
modelIndexList.Add(modelIndex); modelIndexList.Add(modelIndex);
} }
} }
} }
@ -501,7 +512,7 @@ namespace Volo.Abp.Cli.Commands
{ {
var propertyName = (string)property["name"]; var propertyName = (string)property["name"];
propertyName = (char.ToLower(propertyName[0]) + propertyName.Substring(1)); propertyName = (char.ToLower(propertyName[0]) + propertyName.Substring(1));
var typeSimple = (string)property["typeSimple"]; var typeSimple = (string)property["typeSimple"];
var modelIndex = CreateType(data, (string)property["type"], rootPath, modelIndexList); var modelIndex = CreateType(data, (string)property["type"], rootPath, modelIndexList);
@ -536,11 +547,11 @@ namespace Volo.Abp.Cli.Commands
) )
{ {
var typeSimpleModelName = typeSimple.PascalToKebabCase() + ".ts"; var typeSimpleModelName = typeSimple.PascalToKebabCase() + ".ts";
var modelPath = $"src/app/{rootPath}/shared/models/{typeSimpleModelName}"; var modelPath = $"src/app/{rootPath}/shared/models/{typeSimpleModelName}";
if (!File.Exists(modelPath)) if (!File.Exists(modelPath))
{ {
typeSimple = "any" + (typeSimple.Contains("[]") ? "[]" : ""); typeSimple = "any" + (typeSimple.Contains("[]") ? "[]" : "");
} }
} }
if (propertyList.Any(p => p.Key == baseTypeName && p.Value.Any(q => q.Key == propertyName && q.Value == typeSimple))) if (propertyList.Any(p => p.Key == baseTypeName && p.Value.Any(q => q.Key == propertyName && q.Value == typeSimple)))

7
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs

@ -94,7 +94,7 @@ namespace Volo.Abp.Cli.Commands
var createSolutionFolder = (commandLineArgs.Options.GetOrNull(Options.CreateSolutionFolder.Short, Options.CreateSolutionFolder.Long) ?? "true").ToLowerInvariant() != "false"; var createSolutionFolder = (commandLineArgs.Options.GetOrNull(Options.CreateSolutionFolder.Short, Options.CreateSolutionFolder.Long) ?? "true").ToLowerInvariant() != "false";
if (!createSolutionFolder) if (!createSolutionFolder)
{ {
Logger.LogInformation("Create Solution Folder: false"); Logger.LogInformation("Create Solution Folder: no");
} }
var outputFolder = commandLineArgs.Options.GetOrNull(Options.OutputFolder.Short, Options.OutputFolder.Long); var outputFolder = commandLineArgs.Options.GetOrNull(Options.OutputFolder.Short, Options.OutputFolder.Long);
@ -106,10 +106,7 @@ namespace Volo.Abp.Cli.Commands
Path.Combine(outputFolderRoot, SolutionName.Parse(projectName).FullName) : Path.Combine(outputFolderRoot, SolutionName.Parse(projectName).FullName) :
outputFolderRoot; outputFolderRoot;
if (!Directory.Exists(outputFolder)) Volo.Abp.IO.DirectoryHelper.CreateIfNotExists(outputFolder);
{
Directory.CreateDirectory(outputFolder);
}
Logger.LogInformation("Output folder: " + outputFolder); Logger.LogInformation("Output folder: " + outputFolder);

47
modules/docs/src/Volo.Docs.Web/Markdown/MarkdownDocumentToHtmlConverter.cs

@ -1,4 +1,5 @@
using System; using System;
using System.Diagnostics;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
@ -24,9 +25,9 @@ namespace Volo.Docs.Markdown
} }
private const string MdLinkFormat = "[{0}]({1}{2}/{3}/{4}{5}/{6})"; private const string MdLinkFormat = "[{0}]({1}{2}/{3}/{4}{5}/{6})";
private const string MarkdownLinkRegExp = @"\[(.*?)\]\((.*?)\)"; private const string MarkdownLinkRegExp = @"\[(.*?)\]\(((.*?)(\?(.*?))*?)\)";
private const string AnchorLinkRegExp = @"<a[^>]+href=\""(.*?)\""[^>]*>(.*)?</a>"; private const string AnchorLinkRegExp = @"<a[^>]+href=\""(.*?)\""[^>]*>(.*)?</a>";
public virtual string Convert(ProjectDto project, DocumentWithDetailsDto document, string version, public virtual string Convert(ProjectDto project, DocumentWithDetailsDto document, string version,
string languageCode) string languageCode)
{ {
@ -45,7 +46,7 @@ namespace Volo.Docs.Markdown
return _markdownConverter.ConvertToHtml(content); return _markdownConverter.ConvertToHtml(content);
} }
protected virtual string NormalizeLinks( protected virtual string NormalizeLinks(
string content, string content,
string projectShortName, string projectShortName,
@ -53,10 +54,29 @@ namespace Volo.Docs.Markdown
string documentLocalDirectory, string documentLocalDirectory,
string languageCode) string languageCode)
{ {
var normalized = Regex.Replace(content, MarkdownLinkRegExp, delegate (Match match)
var normalized = NormalizeMdLinks(content, projectShortName, version, documentLocalDirectory, languageCode);
normalized = NormalizeAnchorLinks(projectShortName, version, documentLocalDirectory, languageCode, normalized);
return normalized;
}
private string NormalizeMdLinks(string content,
string projectShortName,
string version,
string documentLocalDirectory,
string languageCode)
{
return Regex.Replace(content, MarkdownLinkRegExp, delegate (Match match)
{ {
var link = match.Groups[2].Value; var link = match.Groups[3].Value;
if (UrlHelper.IsExternalLink(link) || !link.EndsWith(".md")) if (UrlHelper.IsExternalLink(link))
{
return match.Value;
}
if (!link.EndsWith(".md"))
{ {
return match.Value; return match.Value;
} }
@ -64,6 +84,13 @@ namespace Volo.Docs.Markdown
var displayText = match.Groups[1].Value; var displayText = match.Groups[1].Value;
var documentName = RemoveFileExtension(link); var documentName = RemoveFileExtension(link);
var hasUrlParameter = match.Groups.Count > 3 && !match.Groups[4].Value.IsNullOrEmpty();
if (hasUrlParameter)
{
documentName += match.Groups[4].Value;
}
var documentLocalDirectoryNormalized = documentLocalDirectory.TrimStart('/').TrimEnd('/'); var documentLocalDirectoryNormalized = documentLocalDirectory.TrimStart('/').TrimEnd('/');
if (!string.IsNullOrWhiteSpace(documentLocalDirectoryNormalized)) if (!string.IsNullOrWhiteSpace(documentLocalDirectoryNormalized))
{ {
@ -81,8 +108,12 @@ namespace Volo.Docs.Markdown
documentName documentName
); );
}); });
}
normalized = Regex.Replace(normalized, AnchorLinkRegExp, delegate (Match match) private string NormalizeAnchorLinks(string projectShortName, string version, string documentLocalDirectory,
string languageCode, string normalized)
{
return Regex.Replace(normalized, AnchorLinkRegExp, delegate (Match match)
{ {
var link = match.Groups[1].Value; var link = match.Groups[1].Value;
if (UrlHelper.IsExternalLink(link)) if (UrlHelper.IsExternalLink(link))
@ -109,8 +140,6 @@ namespace Volo.Docs.Markdown
documentName documentName
); );
}); });
return normalized;
} }
private static string RemoveFileExtension(string documentName) private static string RemoveFileExtension(string documentName)

Loading…
Cancel
Save