Skip to content

Commit

Permalink
fix: Skip header/footer rendering for cover page (#10416)
Browse files Browse the repository at this point in the history
* fix: skip header/footer rendering for cover page

* test(snapshot): update snapshots 3d9aef5

---------

Co-authored-by: filzrev <[email protected]>
Co-authored-by: Yufei Huang <[email protected]>
  • Loading branch information
3 people authored Nov 26, 2024
1 parent 9227ba8 commit 3ff9ae7
Show file tree
Hide file tree
Showing 11 changed files with 1,653 additions and 1,606 deletions.
13 changes: 13 additions & 0 deletions src/Docfx.App/PdfBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ async Task MergePdf()
if (!pageBytes.TryGetValue(node, out var bytes))
continue;

var isCoverPage = url.AbsolutePath.TrimStart('/').Equals(outline.pdfCoverPage, GetStringComparison());

var isTocPage = IsTocPage(url);
if (isTocPage)
{
Expand All @@ -375,6 +377,9 @@ async Task MergePdf()

var pageBuilder = builder.AddPage(document, i, x => CopyLink(node, x));

if (isCoverPage)
continue;

if (isTocPage)
continue;

Expand Down Expand Up @@ -615,4 +620,12 @@ static string getMillimeter(double pt)
return $"{Math.Round(pt * MillimeterPerInch / Dpi)}mm";
}
}

// Gets StringComparison instance for path string.
private static StringComparison GetStringComparison()
{
return PathUtility.IsPathCaseInsensitive()
? StringComparison.OrdinalIgnoreCase
: StringComparison.Ordinal;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"items": [
{
"name": "Namespace",
"name": "Namespaces",
"items": [
{
"name": "MyExample",
Expand All @@ -11,7 +11,7 @@
"type": "Namespace",
"items": [
{
"name": "Class",
"name": "Classes",
"items": [
{
"name": "ExampleClass",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"content": "{\"items\":[{\"name\":\"Namespace\",\"items\":[{\"name\":\"MyExample\",\"href\":\"MyExample.html\",\"topicHref\":\"MyExample.html\",\"topicUid\":\"MyExample\",\"type\":\"Namespace\",\"items\":[{\"name\":\"Class\",\"items\":[{\"name\":\"ExampleClass\",\"href\":\"MyExample.ExampleClass.html\",\"topicHref\":\"MyExample.ExampleClass.html\",\"topicUid\":\"MyExample.ExampleClass\",\"type\":\"Class\",\"items\":[{\"name\":\"Constructors\",\"items\":[{\"name\":\"ExampleClass\",\"href\":\"MyExample.ExampleClass.-ctor.html\",\"topicHref\":\"MyExample.ExampleClass.-ctor.html\",\"topicUid\":\"MyExample.ExampleClass.#ctor*\",\"type\":\"Constructor\",\"fullName\":\"MyExample.ExampleClass.ExampleClass\",\"nameWithType\":\"ExampleClass.ExampleClass\",\"isEii\":false,\"tocHref\":null,\"level\":7,\"items\":[],\"leaf\":true}],\"topicHref\":null,\"tocHref\":null,\"level\":6,\"leaf\":false},{\"name\":\"Properties\",\"items\":[{\"name\":\"MyProperty\",\"href\":\"MyExample.ExampleClass.MyProperty.html\",\"topicHref\":\"MyExample.ExampleClass.MyProperty.html\",\"topicUid\":\"MyExample.ExampleClass.MyProperty*\",\"type\":\"Property\",\"fullName\":\"MyExample.ExampleClass.MyProperty\",\"nameWithType\":\"ExampleClass.MyProperty\",\"isEii\":false,\"tocHref\":null,\"level\":7,\"items\":[],\"leaf\":true}],\"topicHref\":null,\"tocHref\":null,\"level\":6,\"leaf\":false},{\"name\":\"Methods\",\"items\":[{\"name\":\"MyMethod\",\"href\":\"MyExample.ExampleClass.MyMethod.html\",\"topicHref\":\"MyExample.ExampleClass.MyMethod.html\",\"topicUid\":\"MyExample.ExampleClass.MyMethod*\",\"type\":\"Method\",\"fullName\":\"MyExample.ExampleClass.MyMethod\",\"nameWithType\":\"ExampleClass.MyMethod\",\"isEii\":false,\"tocHref\":null,\"level\":7,\"items\":[],\"leaf\":true}],\"topicHref\":null,\"tocHref\":null,\"level\":6,\"leaf\":false},{\"name\":\"Events\",\"items\":[{\"name\":\"MyEvent\",\"href\":\"MyExample.ExampleClass.MyEvent.html\",\"topicHref\":\"MyExample.ExampleClass.MyEvent.html\",\"topicUid\":\"MyExample.ExampleClass.MyEvent\",\"type\":\"Event\",\"fullName\":\"MyExample.ExampleClass.MyEvent\",\"nameWithType\":\"ExampleClass.MyEvent\",\"isEii\":false,\"tocHref\":null,\"level\":7,\"items\":[],\"leaf\":true}],\"topicHref\":null,\"tocHref\":null,\"level\":6,\"leaf\":false}],\"tocHref\":null,\"level\":5,\"leaf\":false}],\"topicHref\":null,\"tocHref\":null,\"level\":4,\"leaf\":false}],\"tocHref\":null,\"level\":3,\"leaf\":false}],\"topicHref\":null,\"tocHref\":null,\"level\":2,\"leaf\":false}],\"memberLayout\":\"SeparatePages\",\"topicHref\":null,\"tocHref\":null,\"name\":null,\"level\":1,\"leaf\":false}"
"content": "{\"items\":[{\"name\":\"Namespaces\",\"items\":[{\"name\":\"MyExample\",\"href\":\"MyExample.html\",\"topicHref\":\"MyExample.html\",\"topicUid\":\"MyExample\",\"type\":\"Namespace\",\"items\":[{\"name\":\"Classes\",\"items\":[{\"name\":\"ExampleClass\",\"href\":\"MyExample.ExampleClass.html\",\"topicHref\":\"MyExample.ExampleClass.html\",\"topicUid\":\"MyExample.ExampleClass\",\"type\":\"Class\",\"items\":[{\"name\":\"Constructors\",\"items\":[{\"name\":\"ExampleClass\",\"href\":\"MyExample.ExampleClass.-ctor.html\",\"topicHref\":\"MyExample.ExampleClass.-ctor.html\",\"topicUid\":\"MyExample.ExampleClass.#ctor*\",\"type\":\"Constructor\",\"fullName\":\"MyExample.ExampleClass.ExampleClass\",\"nameWithType\":\"ExampleClass.ExampleClass\",\"isEii\":false,\"tocHref\":null,\"level\":7,\"items\":[],\"leaf\":true}],\"topicHref\":null,\"tocHref\":null,\"level\":6,\"leaf\":false},{\"name\":\"Properties\",\"items\":[{\"name\":\"MyProperty\",\"href\":\"MyExample.ExampleClass.MyProperty.html\",\"topicHref\":\"MyExample.ExampleClass.MyProperty.html\",\"topicUid\":\"MyExample.ExampleClass.MyProperty*\",\"type\":\"Property\",\"fullName\":\"MyExample.ExampleClass.MyProperty\",\"nameWithType\":\"ExampleClass.MyProperty\",\"isEii\":false,\"tocHref\":null,\"level\":7,\"items\":[],\"leaf\":true}],\"topicHref\":null,\"tocHref\":null,\"level\":6,\"leaf\":false},{\"name\":\"Methods\",\"items\":[{\"name\":\"MyMethod\",\"href\":\"MyExample.ExampleClass.MyMethod.html\",\"topicHref\":\"MyExample.ExampleClass.MyMethod.html\",\"topicUid\":\"MyExample.ExampleClass.MyMethod*\",\"type\":\"Method\",\"fullName\":\"MyExample.ExampleClass.MyMethod\",\"nameWithType\":\"ExampleClass.MyMethod\",\"isEii\":false,\"tocHref\":null,\"level\":7,\"items\":[],\"leaf\":true}],\"topicHref\":null,\"tocHref\":null,\"level\":6,\"leaf\":false},{\"name\":\"Events\",\"items\":[{\"name\":\"MyEvent\",\"href\":\"MyExample.ExampleClass.MyEvent.html\",\"topicHref\":\"MyExample.ExampleClass.MyEvent.html\",\"topicUid\":\"MyExample.ExampleClass.MyEvent\",\"type\":\"Event\",\"fullName\":\"MyExample.ExampleClass.MyEvent\",\"nameWithType\":\"ExampleClass.MyEvent\",\"isEii\":false,\"tocHref\":null,\"level\":7,\"items\":[],\"leaf\":true}],\"topicHref\":null,\"tocHref\":null,\"level\":6,\"leaf\":false}],\"tocHref\":null,\"level\":5,\"leaf\":false}],\"topicHref\":null,\"tocHref\":null,\"level\":4,\"leaf\":false}],\"tocHref\":null,\"level\":3,\"leaf\":false}],\"topicHref\":null,\"tocHref\":null,\"level\":2,\"leaf\":false}],\"memberLayout\":\"SeparatePages\",\"topicHref\":null,\"tocHref\":null,\"name\":null,\"level\":1,\"leaf\":false}"
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

{"items":[{"name":"Namespace","items":[{"name":"MyExample","href":"MyExample.html","topicHref":"MyExample.html","topicUid":"MyExample","type":"Namespace","items":[{"name":"Class","items":[{"name":"ExampleClass","href":"MyExample.ExampleClass.html","topicHref":"MyExample.ExampleClass.html","topicUid":"MyExample.ExampleClass","type":"Class","items":[{"name":"Constructors","items":[{"name":"ExampleClass","href":"MyExample.ExampleClass.-ctor.html","topicHref":"MyExample.ExampleClass.-ctor.html","topicUid":"MyExample.ExampleClass.#ctor*","type":"Constructor","fullName":"MyExample.ExampleClass.ExampleClass","nameWithType":"ExampleClass.ExampleClass","isEii":false,"tocHref":null,"level":7,"items":[],"leaf":true}],"topicHref":null,"tocHref":null,"level":6,"leaf":false},{"name":"Properties","items":[{"name":"MyProperty","href":"MyExample.ExampleClass.MyProperty.html","topicHref":"MyExample.ExampleClass.MyProperty.html","topicUid":"MyExample.ExampleClass.MyProperty*","type":"Property","fullName":"MyExample.ExampleClass.MyProperty","nameWithType":"ExampleClass.MyProperty","isEii":false,"tocHref":null,"level":7,"items":[],"leaf":true}],"topicHref":null,"tocHref":null,"level":6,"leaf":false},{"name":"Methods","items":[{"name":"MyMethod","href":"MyExample.ExampleClass.MyMethod.html","topicHref":"MyExample.ExampleClass.MyMethod.html","topicUid":"MyExample.ExampleClass.MyMethod*","type":"Method","fullName":"MyExample.ExampleClass.MyMethod","nameWithType":"ExampleClass.MyMethod","isEii":false,"tocHref":null,"level":7,"items":[],"leaf":true}],"topicHref":null,"tocHref":null,"level":6,"leaf":false},{"name":"Events","items":[{"name":"MyEvent","href":"MyExample.ExampleClass.MyEvent.html","topicHref":"MyExample.ExampleClass.MyEvent.html","topicUid":"MyExample.ExampleClass.MyEvent","type":"Event","fullName":"MyExample.ExampleClass.MyEvent","nameWithType":"ExampleClass.MyEvent","isEii":false,"tocHref":null,"level":7,"items":[],"leaf":true}],"topicHref":null,"tocHref":null,"level":6,"leaf":false}],"tocHref":null,"level":5,"leaf":false}],"topicHref":null,"tocHref":null,"level":4,"leaf":false}],"tocHref":null,"level":3,"leaf":false}],"topicHref":null,"tocHref":null,"level":2,"leaf":false}],"memberLayout":"SeparatePages","topicHref":null,"tocHref":null,"name":null,"level":1,"leaf":false}
{"items":[{"name":"Namespaces","items":[{"name":"MyExample","href":"MyExample.html","topicHref":"MyExample.html","topicUid":"MyExample","type":"Namespace","items":[{"name":"Classes","items":[{"name":"ExampleClass","href":"MyExample.ExampleClass.html","topicHref":"MyExample.ExampleClass.html","topicUid":"MyExample.ExampleClass","type":"Class","items":[{"name":"Constructors","items":[{"name":"ExampleClass","href":"MyExample.ExampleClass.-ctor.html","topicHref":"MyExample.ExampleClass.-ctor.html","topicUid":"MyExample.ExampleClass.#ctor*","type":"Constructor","fullName":"MyExample.ExampleClass.ExampleClass","nameWithType":"ExampleClass.ExampleClass","isEii":false,"tocHref":null,"level":7,"items":[],"leaf":true}],"topicHref":null,"tocHref":null,"level":6,"leaf":false},{"name":"Properties","items":[{"name":"MyProperty","href":"MyExample.ExampleClass.MyProperty.html","topicHref":"MyExample.ExampleClass.MyProperty.html","topicUid":"MyExample.ExampleClass.MyProperty*","type":"Property","fullName":"MyExample.ExampleClass.MyProperty","nameWithType":"ExampleClass.MyProperty","isEii":false,"tocHref":null,"level":7,"items":[],"leaf":true}],"topicHref":null,"tocHref":null,"level":6,"leaf":false},{"name":"Methods","items":[{"name":"MyMethod","href":"MyExample.ExampleClass.MyMethod.html","topicHref":"MyExample.ExampleClass.MyMethod.html","topicUid":"MyExample.ExampleClass.MyMethod*","type":"Method","fullName":"MyExample.ExampleClass.MyMethod","nameWithType":"ExampleClass.MyMethod","isEii":false,"tocHref":null,"level":7,"items":[],"leaf":true}],"topicHref":null,"tocHref":null,"level":6,"leaf":false},{"name":"Events","items":[{"name":"MyEvent","href":"MyExample.ExampleClass.MyEvent.html","topicHref":"MyExample.ExampleClass.MyEvent.html","topicUid":"MyExample.ExampleClass.MyEvent","type":"Event","fullName":"MyExample.ExampleClass.MyEvent","nameWithType":"ExampleClass.MyEvent","isEii":false,"tocHref":null,"level":7,"items":[],"leaf":true}],"topicHref":null,"tocHref":null,"level":6,"leaf":false}],"tocHref":null,"level":5,"leaf":false}],"topicHref":null,"tocHref":null,"level":4,"leaf":false}],"tocHref":null,"level":3,"leaf":false}],"topicHref":null,"tocHref":null,"level":2,"leaf":false}],"memberLayout":"SeparatePages","topicHref":null,"tocHref":null,"name":null,"level":1,"leaf":false}
Loading

0 comments on commit 3ff9ae7

Please sign in to comment.