-
Notifications
You must be signed in to change notification settings - Fork 867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic static rendering #3411
Changes from 9 commits
218757c
dd6fbe0
cd1576d
0f1cdd8
92acb20
7552a85
87c2400
cf49cd2
fc16e2b
7121f1a
cd9f6b5
072d553
7bb7582
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
# Apply template and produce html page when output is not json | ||
inputs: | ||
docfx.yml: | | ||
output: | ||
json: false | ||
docs/a.md: | ||
outputs: | ||
docs/a/index.html: | ||
build.manifest: | ||
--- | ||
# Use .html extension on uglify url | ||
inputs: | ||
docfx.yml: | | ||
output: | ||
json: false | ||
uglifyUrl: true | ||
docs/a.md: | ||
outputs: | ||
docs/a.html: | ||
build.manifest: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"html": { | ||
"type": "string" | ||
}, | ||
"title": { | ||
"type": "string" | ||
}, | ||
"htmlTitle": { | ||
"type": "string" | ||
}, | ||
"wordCount": { | ||
"type": "integer" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,17 @@ internal sealed class OutputConfig | |
/// </summary> | ||
public readonly string Path = "_site"; | ||
|
||
/// <summary> | ||
/// Gets whether to output JSON model. | ||
/// </summary> | ||
public readonly bool Json = false; | ||
|
||
/// <summary> | ||
/// Gets whether to include `.html` in urls. | ||
/// The default value is to generate an `index.html` for each article. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Is this comment for Json? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. clarified in comments |
||
/// </summary> | ||
public readonly bool UglifyUrl = false; | ||
|
||
/// <summary> | ||
/// Gets whether resources are copied to output. | ||
/// </summary> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,28 +8,34 @@ namespace Microsoft.Docs.Build | |
public static class DocumentTest | ||
{ | ||
[Theory] | ||
[InlineData("docfx.yml", ContentType.Unknown, "docfx.yml", "/docfx.yml", "docfx.yml")] | ||
[InlineData("docfx.json", ContentType.Unknown, "docfx.json", "/docfx.json", "docfx.json")] | ||
[InlineData("a.md", ContentType.Page, "a.json", "/a", "a")] | ||
[InlineData("a/b.md", ContentType.Page, "a/b.json", "/a/b", "a/b")] | ||
[InlineData("index.md", ContentType.Page, "index.json", "/", ".")] | ||
[InlineData("a/index.md", ContentType.Page, "a/index.json", "/a/", "a/")] | ||
[InlineData("a.yml", ContentType.Page, "a.json", "/a", "a")] | ||
[InlineData("a/index.yml", ContentType.Page, "a/index.json", "/a/", "a/")] | ||
[InlineData("TOC.md", ContentType.TableOfContents, "TOC.json", "/TOC.json", "TOC.json")] | ||
[InlineData("TOC.yml", ContentType.TableOfContents, "TOC.json", "/TOC.json", "TOC.json")] | ||
[InlineData("TOC.json", ContentType.TableOfContents, "TOC.json", "/TOC.json", "TOC.json")] | ||
[InlineData("image.png", ContentType.Resource, "image.png", "/image.png", "image.png")] | ||
[InlineData("a&#/b\\.* d.png", ContentType.Resource, "a&#/b\\.* d.png", "/a&#/b/.* d.png", "a&#/b/.* d.png")] | ||
[InlineData("docfx.yml", true, false, ContentType.Unknown, "docfx.yml", "/docfx.yml", "docfx.yml")] | ||
[InlineData("docfx.json", true, false, ContentType.Unknown, "docfx.json", "/docfx.json", "docfx.json")] | ||
[InlineData("a.md", true, false, ContentType.Page, "a.json", "/a", "a")] | ||
[InlineData("a/b.md", true, false, ContentType.Page, "a/b.json", "/a/b", "a/b")] | ||
[InlineData("index.md", true, false, ContentType.Page, "index.json", "/", ".")] | ||
[InlineData("a/index.md", true, false, ContentType.Page, "a/index.json", "/a/", "a/")] | ||
[InlineData("a.yml", true, false, ContentType.Page, "a.json", "/a", "a")] | ||
[InlineData("a/index.yml", true, false, ContentType.Page, "a/index.json", "/a/", "a/")] | ||
[InlineData("TOC.md", true, false, ContentType.TableOfContents, "TOC.json", "/TOC.json", "TOC.json")] | ||
[InlineData("TOC.yml", true, false, ContentType.TableOfContents, "TOC.json", "/TOC.json", "TOC.json")] | ||
[InlineData("TOC.json", true, false, ContentType.TableOfContents, "TOC.json", "/TOC.json", "TOC.json")] | ||
[InlineData("image.png", true, false, ContentType.Resource, "image.png", "/image.png", "image.png")] | ||
[InlineData("a&#/b\\.* d.png", true, false, ContentType.Resource, "a&#/b\\.* d.png", "/a&#/b/.* d.png", "a&#/b/.* d.png")] | ||
[InlineData("a.md", false, false, ContentType.Page, "a/index.html", "/a/", "a/")] | ||
[InlineData("a.md", false, true, ContentType.Page, "a.html", "/a", "a")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
should this be "a.html", "/a.html", "a.html"? |
||
[InlineData("a/index.md", false, false, ContentType.Page, "a/index.html", "/a/", "a/")] | ||
[InlineData("a/index.md", false, true, ContentType.Page, "a/index.html", "/a/", "a/")] | ||
internal static void FilePathToUrl( | ||
string path, | ||
bool json, | ||
bool uglifyUrl, | ||
ContentType expectedContentType, | ||
string expectedSitePath, | ||
string expectedSiteUrl, | ||
string expectedRelativeSiteUrl) | ||
{ | ||
Assert.Equal(expectedContentType, Document.GetContentType(path)); | ||
Assert.Equal(expectedSitePath, Document.FilePathToSitePath(path, expectedContentType, null)); | ||
Assert.Equal(expectedSitePath, Document.FilePathToSitePath(path, expectedContentType, null, json, uglifyUrl)); | ||
Assert.Equal(expectedSiteUrl, Document.PathToAbsoluteUrl(expectedSitePath, expectedContentType, null)); | ||
Assert.Equal(expectedRelativeSiteUrl, Document.PathToRelativeUrl(expectedSitePath, expectedContentType, null)); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ rules: | |
heading-not-found: off | ||
resolve-author-failed: off | ||
resolve-commit-failed: off | ||
output: | ||
json: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be PageModel or string, but
Build.cs
always usescontext.WriteJson
to write it. Add acontext.WriteString
when it's string?