mirror of https://github.com/NewLifeX/XDoc.git

16 changed files with 589 additions and 83 deletions
-
1articles/CubeCore/index.md
-
1articles/CubeCore/中级教程/index.md
-
0articles/CubeCore/中级教程/自定义高级查询.md
-
1articles/CubeCore/入门教程/index.md
-
0articles/CubeCore/入门教程/运行.md
-
124articles/CubeCore/魔方core.md
-
1articles/build-toc.ps1
-
60articles/toc-temp.md
-
60articles/toc.md
-
45articles/toc.yml
-
42build/PowerShellProject1.pssproj
-
25build/PowerShellProject1.sln
-
200build/build-toc.ps1
-
42build/build.ps1
-
66docfx.json
-
4toc.yml
@ -0,0 +1 @@ |
|||
# 魔方core版介绍 |
@ -0,0 +1 @@ |
|||
# 魔方中级教程 |
@ -0,0 +1 @@ |
|||
# 入门教程 |
@ -0,0 +1,124 @@ |
|||
# 魔方core说明 |
|||
|
|||
## 菜单注册 |
|||
|
|||
### 区域使用AreaBaseX区域特性 |
|||
|
|||
- 自定义一个继承AreaBaseX的区域特性类,命名为“区域名”+“Area” |
|||
- 继承构造函数base(areaName) |
|||
- 定义的新区域特性要声明一个静态构造函数,调用RegisterArea静态方法 |
|||
- 示例 |
|||
|
|||
```csharp |
|||
/// <summary>权限管理区域注册</summary> |
|||
[DisplayName("系统管理")] |
|||
public class AdminArea : AreaBaseX |
|||
{ |
|||
public static string AreaName => nameof(AdminArea).TrimEnd("Area"); |
|||
|
|||
/// <inheritdoc /> |
|||
public AdminArea() : base(AreaName) |
|||
{ |
|||
|
|||
} |
|||
|
|||
static AdminArea() |
|||
{ |
|||
RegisterArea<AdminArea>(); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
- 如果不使用AreaBaseX区域特性路由,添加权限特性EntityAuthorizeAttribute,会自动添加此菜单 |
|||
|
|||
- 在区域控制器加上上面区域特性类 |
|||
|
|||
```csharp |
|||
[AdminArea] |
|||
public class UserController : EntityController<UserX> |
|||
{ |
|||
|
|||
} |
|||
``` |
|||
|
|||
### 控制器设置 |
|||
|
|||
- 如果控制器继承自魔方的功能控制器,那么会默认菜单相关选项 |
|||
- 如果需要自定义,则需要继承自`ControllerBaseX` |
|||
- 重载`ScanActionMenu`方法,将菜单设置为可见`menu.Visible = true` |
|||
- 声明一个静态变量设置菜单顺序`protected static Int32 MenuOrder { get; set; } = 100;` |
|||
- 示例 |
|||
|
|||
```csharp |
|||
[ApiArea] |
|||
[DisplayName("SwaggerApi")] |
|||
[Description("SwaggerApi")] |
|||
public class SwaggerController : ControllerBaseX |
|||
{ |
|||
|
|||
protected static Int32 MenuOrder { get; set; } = 100; |
|||
|
|||
protected override IDictionary<MethodInfo, int> ScanActionMenu(IMenu menu) |
|||
{ |
|||
// 设置显示名 |
|||
if (menu.DisplayName.IsNullOrEmpty()) |
|||
{ |
|||
menu.DisplayName = typeof(SwaggerController).GetCustomAttribute<DisplayNameAttribute>().DisplayName; |
|||
menu.Visible = true; |
|||
} |
|||
|
|||
var dic = base.ScanActionMenu(menu); |
|||
|
|||
return dic; |
|||
} |
|||
|
|||
// GET: Swagger |
|||
[EntityAuthorize(PermissionFlags.Detail)] |
|||
public ActionResult Index() |
|||
{ |
|||
return View(); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
或者 |
|||
|
|||
```csharp |
|||
[ApiArea] |
|||
public class HomeController : EntityController<UserX> |
|||
{ |
|||
public override ActionResult Index(Pager p = null) |
|||
{ |
|||
return View(); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 视图 |
|||
|
|||
### 覆盖优先级 |
|||
|
|||
- 如果项目添加并引用Razor类库,那么它的优先级仅次于项目自身的视图 |
|||
- 其次,要引用nuget包里面的视图或者直接引用一个视图dll,需要手动进行注册,否则不会被出现在系统的查找范围 |
|||
- 可以同时存在多个视图资源,通过这个优先级选择对应视图,请查看下面更多说明 |
|||
- 魔方的视图结构请[查看这里](查看这里还什么也没有) |
|||
|
|||
### 注册方法 |
|||
|
|||
- 可通过`typeof(Areas_Admin_Views_Index_Index).Assembly.FullName`这样子的名称获得视图所在程序集名称,注册方法如下 |
|||
|
|||
```csharp |
|||
services.AddCustomApplicationParts(asmNaneList => |
|||
{ |
|||
asmNaneList.Add(typeof(Areas_Admin_Views_Index_Index).Assembly.FullName); |
|||
}); |
|||
``` |
|||
|
|||
- 如果你想进行模块化开发,加载多个包含控制器的程序集,也是使用上面的方法进行注册 |
|||
- 但请注意控制名不要重复,否则你需要在对[路由命名空间优先级](这部分还没有说明)进行设置 |
|||
|
|||
### 更多说明 |
|||
|
|||
- 所有编译之后的视图程序集,生成的类名和命名空间都是一样的,所以如果同时引用多个含有视图的nuget包,编译器会`typeof(Areas_Admin_Views_Index_Index)`在这里报错 |
|||
- 那为什么Razor类库和项目本身都存在同样名字的视图,又不会报错呢?因为它们都还是源代码,还没编译啊。 |
|||
- core mvc 加载项目本身的控制器和视图的方法`ApplicationPartManager.PopulateDefaultParts`是内部的,不能调用,里面会根据引入的外部控制器所在程序集(比如你的项目引用了A程序集),寻找所有依赖于A程序集的程序集(比如A程序集对应的`A.Views.dll`),一起加载进系统成为系统的一部分。魔方提供`AddCustomApplicationParts`拓展方法自定义加载程序集,即使`A.Views.dll`依赖于A,你也可以选择不加载`A.Views.dll`,通过自己实现自己视图来呈现页面,给你更多的选择! |
@ -0,0 +1 @@ |
|||
. ../build/build-toc.ps1 $PSScriptRoot |
@ -0,0 +1,60 @@ |
|||
# [介绍](index.md) |
|||
|
|||
# Agent |
|||
## [Readme](Agent/Readme.MD) |
|||
|
|||
# Api |
|||
## [Readme](Api/Readme.MD) |
|||
|
|||
# Cube |
|||
## [Readme](Cube/Readme.MD) |
|||
|
|||
# [CubeCore](CubeCore/index.md) |
|||
## 中级教程 |
|||
### [自定义高级查询](CubeCore/中级教程/自定义高级查询.md) |
|||
## 入门教程 |
|||
### [运行](CubeCore/入门教程/运行.md) |
|||
## [魔方core](CubeCore/魔方core.md) |
|||
|
|||
# [DotNetCore](DotNetCore/index.md) |
|||
## [netcore_centos](DotNetCore/netcore_centos.md) |
|||
|
|||
# Mobile |
|||
## [Readme](Mobile/Readme.MD) |
|||
|
|||
# Net |
|||
## [Readme](Net/Readme.MD) |
|||
## [新生命网络库客户端用法](Net/新生命网络库客户端用法.md) |
|||
## [新生命网络库比较典型的简单用法](Net/新生命网络库比较典型的简单用法.md) |
|||
|
|||
# Reflect |
|||
## [Readme](Reflect/Readme.MD) |
|||
|
|||
# Security |
|||
## [Readme](Security/Readme.MD) |
|||
|
|||
# Serialization |
|||
## [Readme](Serialization/Readme.MD) |
|||
|
|||
# Thread |
|||
## [Readme](Thread/Readme.MD) |
|||
|
|||
# XCode |
|||
## [EntityCache](XCode/EntityCache.MD) |
|||
## [ExtendProperty](XCode/ExtendProperty.MD) |
|||
## [Get-Start](XCode/Get-Start.MD) |
|||
## [Migration](XCode/Migration.MD) |
|||
## [Model](XCode/Model.MD) |
|||
## [Normal](XCode/Normal.MD) |
|||
## [Readme](XCode/Readme.MD) |
|||
## [Search](XCode/Search.MD) |
|||
## [SingleCache](XCode/SingleCache.MD) |
|||
|
|||
# XCoder |
|||
## [Readme](XCoder/Readme.MD) |
|||
|
|||
# XScript |
|||
## [Readme](XScript/Readme.MD) |
|||
|
|||
# XTemplate |
|||
## [Readme](XTemplate/Readme.MD) |
@ -0,0 +1,60 @@ |
|||
# [介绍](index.md) |
|||
|
|||
# Agent |
|||
## [Readme](Agent/Readme.MD) |
|||
|
|||
# Api |
|||
## [Readme](Api/Readme.MD) |
|||
|
|||
# Cube |
|||
## [Readme](Cube/Readme.MD) |
|||
|
|||
# [CubeCore](CubeCore/index.md) |
|||
## 中级教程 |
|||
### [自定义高级查询](CubeCore/中级教程/自定义高级查询.md) |
|||
## 入门教程 |
|||
### [运行](CubeCore/入门教程/运行.md) |
|||
## [魔方core](CubeCore/魔方core.md) |
|||
|
|||
# [DotNetCore](DotNetCore/index.md) |
|||
## [netcore_centos](DotNetCore/netcore_centos.md) |
|||
|
|||
# Mobile |
|||
## [Readme](Mobile/Readme.MD) |
|||
|
|||
# Net |
|||
## [Readme](Net/Readme.MD) |
|||
## [新生命网络库客户端用法](Net/新生命网络库客户端用法.md) |
|||
## [新生命网络库比较典型的简单用法](Net/新生命网络库比较典型的简单用法.md) |
|||
|
|||
# Reflect |
|||
## [Readme](Reflect/Readme.MD) |
|||
|
|||
# Security |
|||
## [Readme](Security/Readme.MD) |
|||
|
|||
# Serialization |
|||
## [Readme](Serialization/Readme.MD) |
|||
|
|||
# Thread |
|||
## [Readme](Thread/Readme.MD) |
|||
|
|||
# XCode |
|||
## [EntityCache](XCode/EntityCache.MD) |
|||
## [ExtendProperty](XCode/ExtendProperty.MD) |
|||
## [Get-Start](XCode/Get-Start.MD) |
|||
## [Migration](XCode/Migration.MD) |
|||
## [Model](XCode/Model.MD) |
|||
## [Normal](XCode/Normal.MD) |
|||
## [Readme](XCode/Readme.MD) |
|||
## [Search](XCode/Search.MD) |
|||
## [SingleCache](XCode/SingleCache.MD) |
|||
|
|||
# XCoder |
|||
## [Readme](XCoder/Readme.MD) |
|||
|
|||
# XScript |
|||
## [Readme](XScript/Readme.MD) |
|||
|
|||
# XTemplate |
|||
## [Readme](XTemplate/Readme.MD) |
@ -1,45 +0,0 @@ |
|||
- name: 介绍 |
|||
href: index.md |
|||
- name: Agent |
|||
href: Agent/Readme.MD |
|||
- name: Api |
|||
href: Api/Readme.MD |
|||
- name: Cube |
|||
href: Cube/Readme.MD |
|||
- name: Mobile |
|||
href: Mobile/Readme.MD |
|||
- name: Net |
|||
href: Net/Readme.MD |
|||
- name: Reflect |
|||
href: Reflect/Readme.MD |
|||
- name: Security |
|||
href: Security/Readme.MD |
|||
- name: Serialization |
|||
href: Serialization/Readme.MD |
|||
- name: Thread |
|||
href: Thread/Readme.MD |
|||
- name: XCode |
|||
href: XCode/Readme.MD |
|||
items: |
|||
- name: 入门教程 |
|||
href: XCode/Get-Start.MD |
|||
- name: 实体缓存 |
|||
href: XCode/EntityCache.MD |
|||
- name: 扩展属性 |
|||
href: XCode/ExtendProperty.MD |
|||
- name: 反向工程 |
|||
href: XCode/Migration.MD |
|||
- name: 实体模型 |
|||
href: XCode/Model.MD |
|||
- name: 基本操作 |
|||
href: XCode/Normal.MD |
|||
- name: 复杂查询 |
|||
href: XCode/Search.MD |
|||
- name: 对象缓存 |
|||
href: XCode/SingleCache.MD |
|||
- name: XCoder |
|||
href: XCoder/Readme.MD |
|||
- name: XScript |
|||
href: XScript/Readme.MD |
|||
- name: XTemplate |
|||
href: XTemplate/Readme.MD |
@ -0,0 +1,42 @@ |
|||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|||
<SchemaVersion>2.0</SchemaVersion> |
|||
<ProjectGuid>{a3746209-cf63-423b-b96a-bb2edcb1b00b}</ProjectGuid> |
|||
<OutputType>Exe</OutputType> |
|||
<RootNamespace>MyApplication</RootNamespace> |
|||
<AssemblyName>MyApplication</AssemblyName> |
|||
<Name>PowerShellProject1</Name> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
<DebugSymbols>true</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Folder Include="articles\" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Compile Include="..\articles\build-toc.ps1"> |
|||
<Link>articles\build-toc.ps1</Link> |
|||
</Compile> |
|||
<Compile Include="build-toc.ps1" /> |
|||
<Compile Include="build.ps1"> |
|||
</Compile> |
|||
</ItemGroup> |
|||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
|||
<Target Name="Build" /> |
|||
<Import Project="$(MSBuildExtensionsPath)\PowerShell Tools for Visual Studio\PowerShellTools.targets" Condition="Exists('$(MSBuildExtensionsPath)\PowerShell Tools for Visual Studio\PowerShellTools.targets')" /> |
|||
</Project> |
@ -0,0 +1,25 @@ |
|||
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00 |
|||
# Visual Studio 15 |
|||
VisualStudioVersion = 15.0.27703.2042 |
|||
MinimumVisualStudioVersion = 10.0.40219.1 |
|||
Project("{F5034706-568F-408A-B7B3-4D38C6DB8A32}") = "PowerShellProject1", "PowerShellProject1.pssproj", "{A3746209-CF63-423B-B96A-BB2EDCB1B00B}" |
|||
EndProject |
|||
Global |
|||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|||
Debug|Any CPU = Debug|Any CPU |
|||
Release|Any CPU = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|||
{A3746209-CF63-423B-B96A-BB2EDCB1B00B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{A3746209-CF63-423B-B96A-BB2EDCB1B00B}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{A3746209-CF63-423B-B96A-BB2EDCB1B00B}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{A3746209-CF63-423B-B96A-BB2EDCB1B00B}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(SolutionProperties) = preSolution |
|||
HideSolutionNode = FALSE |
|||
EndGlobalSection |
|||
GlobalSection(ExtensibilityGlobals) = postSolution |
|||
SolutionGuid = {1B2034ED-EC63-4AEA-81D8-6D0D65453BBB} |
|||
EndGlobalSection |
|||
EndGlobal |
@ -0,0 +1,200 @@ |
|||
# |
|||
# 生成一个栏目里面所有内容的菜单 |
|||
# |
|||
|
|||
param($Directory) |
|||
|
|||
class Toc { |
|||
Toc($content) { |
|||
$this.TContent = $content |
|||
} |
|||
|
|||
[string[]] $TContent |
|||
[Collections.Generic.List[TocItem]] $Items = [Collections.Generic.List[TocItem]]::new(4) |
|||
|
|||
# 转化成对象 |
|||
[TocItem[]] ToToc($i, [TocItem[]] $tocItems) { |
|||
$content = $this.TContent |
|||
|
|||
for (; $i -lt $content.Length; $i++) { |
|||
[string] $item = $content[$i] |
|||
|
|||
if (!$item.TrimStart(" ").StartsWith("- name")) { |
|||
continue |
|||
} |
|||
|
|||
[TocItem] $tocItem = [TocItem]::new() |
|||
|
|||
if ($tocItems.Count -eq 0 ) { |
|||
$tocItems = @($tocItem) |
|||
} |
|||
else { |
|||
$tocItems = $tocItems + $tocItem |
|||
} |
|||
|
|||
|
|||
#$tocItems.Add($tocItem) |
|||
|
|||
$tocItem.Name = $item |
|||
|
|||
$item = $content[$i + 1] |
|||
|
|||
if ($item.TrimStart(" ").StartsWith("href")) { |
|||
$tocItem.Href = $item |
|||
$i++ |
|||
$item = $content[$i + 1] |
|||
} |
|||
|
|||
if ($item.TrimStart(" ").StartsWith("items")) { |
|||
$tocItem.Items = [Collections.Generic.List[TocItem]]::new() |
|||
$i++ |
|||
$this.ToToc($i, $tocItem.Items) |
|||
} |
|||
} |
|||
|
|||
return $tocItems |
|||
} |
|||
|
|||
[string] ToString () { |
|||
return "666" |
|||
} |
|||
} |
|||
|
|||
class TocItem { |
|||
[string] $Name |
|||
[string] $Href |
|||
[Collections.Generic.List[TocItem]] $Items |
|||
} |
|||
|
|||
|
|||
|
|||
# 目录文件 |
|||
$tocPath = $Directory + "/toc.md" |
|||
|
|||
# 目录内容 |
|||
[Collections.Generic.List[string]] $tocContent |
|||
|
|||
#新目录内容 |
|||
[String[]] $newTocContent |
|||
|
|||
# 获取目录内容 |
|||
If (Test-Path $tocPath) { |
|||
$tocContent = Get-Content -Path $tocPath -Encoding UTF8 |
|||
} |
|||
|
|||
#$toc = [Toc]::new($tocContent) |
|||
#$toc.ToToc(0, $toc.Items) |
|||
#$toc.ToString() |
|||
|
|||
# 构建目录 |
|||
function buildToc($dirPath) { |
|||
|
|||
# 首先判断当前目录是否有md文件或者文件夹,没有则返回 |
|||
|
|||
#If(Test-Path ($dirPath + "/index.md")){ |
|||
# $tocContent = Get-Content -Encoding UTF8 |
|||
#} |
|||
|
|||
[String[]] $newTocContent |
|||
|
|||
# 获取文件信息,-Recurse表示遍历子目录 |
|||
$fileInfo = Get-ChildItem $dirPath -Recurse -Include *.md -Exclude index.md,toc*.md |
|||
|
|||
# 记录上一次父级文件夹到该栏目 $Directory 的路径 |
|||
$pPath = "" |
|||
|
|||
$fileInfo | foreach { |
|||
# 链接地址 |
|||
$linkName = $_.FullName.Replace($Directory, "").TrimStart("\\") |
|||
|
|||
# 深度,根据深度来生成层级关系 |
|||
$depth = $linkName.Split('\\').Length - 1 |
|||
|
|||
# 文件到栏目文件夹的路径 |
|||
$linkPath = $linkName.Replace($_.Name, "").TrimEnd("\\") |
|||
|
|||
# 如果当前路径与上一次记录的路径不同,则检查生成父级 items |
|||
If (!($linkPath -eq $pPath)) { |
|||
|
|||
#生成父级标题 |
|||
$titleContent = $null |
|||
$titleContent = buildItems($linkPath, $dirPath) |
|||
$newTocContent = $newTocContent + $titleContent |
|||
|
|||
# 更新父级 |
|||
$pPath = $linkPath |
|||
} |
|||
|
|||
$sharps = getSharp($depth) |
|||
|
|||
$newTocContent = $newTocContent + ($sharps + "[" + $_.BaseName + "](" + ($linkName -replace "\\","/") + ")") |
|||
} |
|||
|
|||
# 如果根目录含有index.md,添加一个目录 |
|||
if(Test-Path ([System.IO.Path]::Combine($dirPath, "index.md"))) |
|||
{ |
|||
$newTocContent = @("# [介绍](index.md)") + $newTocContent |
|||
} |
|||
|
|||
return $newTocContent |
|||
} |
|||
|
|||
# 生成父级标题 |
|||
function buildItems($arg) { |
|||
|
|||
$linkPath = $arg[0] |
|||
$base = $arg[1] |
|||
|
|||
$arr = $linkPath -split "\\" |
|||
$content = @() |
|||
|
|||
for ($i = 0; $i -lt $arr.Length; $i++) { |
|||
|
|||
$_ = $arr[$i] |
|||
|
|||
# 获取间隔 |
|||
$sharps = getSharp($i) |
|||
|
|||
$title = $null |
|||
|
|||
$indexMDFile = [System.IO.Path]::Combine($base, $_, "index.md") |
|||
|
|||
if(Test-Path $indexMDFile) |
|||
{ |
|||
$title = $sharps + "[" + $_ + "](" + $_ + "/" + "index.md)" |
|||
}else |
|||
{ |
|||
$title = $sharps + $_ |
|||
} |
|||
|
|||
# 如果已经存在此标题,跳过 |
|||
if(-not($newTocContent -contains $title)) |
|||
{ |
|||
# 如果这次是顶级标题,则加一空行 |
|||
if($sharps -eq "# ") |
|||
{ |
|||
$content = $content + "" + $title |
|||
} |
|||
else |
|||
{ |
|||
$content = $content + $title |
|||
} |
|||
} |
|||
} |
|||
|
|||
return $content |
|||
} |
|||
|
|||
# 根据深度获取 # 符号 |
|||
function getSharp($depth) { |
|||
$depth++ |
|||
$share = "" |
|||
for ($i = 0; $i -lt $depth; $i++) { |
|||
$share += "#" |
|||
} |
|||
|
|||
return $share + " " |
|||
} |
|||
|
|||
$newToc = buildToc($Directory); |
|||
$newToc | Out-File "utf8" -FilePath ([System.IO.Path]::Combine($Directory, "toc-temp.md")) |
@ -0,0 +1,42 @@ |
|||
$basePath = "../" |
|||
|
|||
# 生成菜单 |
|||
|
|||
# 生成顶部栏菜单 |
|||
|
|||
# 读取配置文件 |
|||
$docfxJson = Get-Content -Path ($basePath + "docfx.json") |
|||
|
|||
# 解析成对象 |
|||
$docfxJsonObj = $docfxJson | ConvertFrom-Json |
|||
|
|||
# 获取需要编译的内容 |
|||
$content = $docfxJsonObj.build.content |
|||
|
|||
# 循环编译的内容条目,获得所有文件夹 |
|||
$dirList = $null |
|||
foreach($item in $content){ |
|||
$files = $item.files |
|||
foreach($file in $files){ |
|||
$i = $file.IndexOf("/") |
|||
If($i -gt 0){ |
|||
$dirName = $file.Substring(0,$i) |
|||
$dirList = $dirList, $dirName |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
# 生成栏目内容 |
|||
$topTocContent = $null |
|||
foreach($item in $dirList){ |
|||
$topTocContent = $topTocContent + ("- name: "+$item), (" href: "+$item+"/") |
|||
} |
|||
|
|||
# 每一个文件夹视为一个栏目,生成根目录下的toc.yml |
|||
$topTocPath = ($basePath + "toc.yml") |
|||
If(!(Test-Path $topTocPath)){ |
|||
|
|||
} |
|||
|
|||
$topTocContent | Out-File -FilePath $topTocPath -Encoding utf8 |
@ -1,4 +1,4 @@ |
|||
- name: api |
|||
href: api/ |
|||
- name: 教程 |
|||
href: articles/ |
|||
- name: Api 文档 |
|||
href: api/ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue