diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index ae674cc01..310e6df70 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +## 16.0.3 +* [Fix link translation when using relative input path](https://github.com/fsprojects/FSharp.Formatting/issues/764) + ## 16.0.2 * [Improves markdown emphasis parsing.](https://github.com/fsprojects/FSharp.Formatting/pull/763) diff --git a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs index 6b6df752a..582d09ff6 100644 --- a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs +++ b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs @@ -1447,7 +1447,7 @@ module internal SymbolReader = | _, _, ".ctor", _, _ -> span [] [ !!v.ApparentEnclosingEntity.DisplayName; fullArgUsage ] // Indexers - | _, true, _, "Item", _ -> span [] [ !! "this.["; fullArgUsage; !! "]" ] + | _, true, _, "Item", _ -> span [] [ !! "this["; fullArgUsage; !! "]" ] // Custom operators | _, _, _, _, Some name -> @@ -1944,6 +1944,7 @@ module internal SymbolReader = | false -> let lang = elem.Attribute("lang").Value $"{lang} language-{lang}" + html.Append("
") |> ignore
                     html.Append($"") |> ignore
 
diff --git a/src/FSharp.Formatting.CodeFormat/CommentFilter.fs b/src/FSharp.Formatting.CodeFormat/CommentFilter.fs
index b53c7aab7..dbf75777a 100644
--- a/src/FSharp.Formatting.CodeFormat/CommentFilter.fs
+++ b/src/FSharp.Formatting.CodeFormat/CommentFilter.fs
@@ -2,7 +2,7 @@
 // F# CodeFormat (CommentProcessing.fs)
 // (c) Tomas Petricek, 2012, Available under Apache 2.0 license.
 // --------------------------------------------------------------------------------------
-module private FSharp.Formatting.CodeFormat.CommentFilter
+module internal FSharp.Formatting.CodeFormat.CommentFilter
 
 open System.Text
 open FSharp.Patterns
diff --git a/src/FSharp.Formatting.CodeFormat/ToolTipReader.fs b/src/FSharp.Formatting.CodeFormat/ToolTipReader.fs
index 3f34b5ac8..69534ba7f 100644
--- a/src/FSharp.Formatting.CodeFormat/ToolTipReader.fs
+++ b/src/FSharp.Formatting.CodeFormat/ToolTipReader.fs
@@ -2,7 +2,7 @@
 // F# CodeFormat (ToolTipReader.fs)
 // (c) Tomas Petricek, 2012, Available under Apache 2.0 license.
 // --------------------------------------------------------------------------------------
-module private FSharp.Formatting.CodeFormat.ToolTipReader
+module internal FSharp.Formatting.CodeFormat.ToolTipReader
 
 open System
 open System.IO
diff --git a/src/fsdocs-tool/BuildCommand.fs b/src/fsdocs-tool/BuildCommand.fs
index 1290a0477..56e2097f8 100644
--- a/src/fsdocs-tool/BuildCommand.fs
+++ b/src/fsdocs-tool/BuildCommand.fs
@@ -100,7 +100,7 @@ type internal DocContent
         =
         let markdownReferenceAsFullInputPathOpt =
             try
-                Path.GetFullPath(markdownReference, inputFolderAsGiven) |> Some
+                Path.GetFullPath(Path.Combine(inputFolderAsGiven, markdownReference)) |> Some
             with _ ->
                 None
 
diff --git a/tests/FSharp.Literate.Tests/DocContentTests.fs b/tests/FSharp.Literate.Tests/DocContentTests.fs
index 215c6c97b..8250572fe 100644
--- a/tests/FSharp.Literate.Tests/DocContentTests.fs
+++ b/tests/FSharp.Literate.Tests/DocContentTests.fs
@@ -42,24 +42,121 @@ let ``Can build doc content`` () =
         action globals
 
     // Check simple1.fsx --> simple1.html substititions
+    // Check simple2.md --> simple2.html substititions
     let html1 = File.ReadAllText(rootOutputFolderAsGiven  "simple1.html")
     let html2 = File.ReadAllText(rootOutputFolderAsGiven  "simple2.html")
-    html1 |> shouldContainText "simple2.html"
-    html2 |> shouldContainText "simple1.html"
+    html1 |> shouldContainText """href="simple1.html">"""
+    html1 |> shouldContainText """href="simple2.html">"""
+    html2 |> shouldContainText """href="simple1.html">"""
+    html2 |> shouldContainText """href="simple2.html">"""
 
     // Check simple1.fsx --> simple1.ipynb substititions
+    // Check simple2.md --> simple1.ipynb substititions
     let ipynb1 = File.ReadAllText(rootOutputFolderAsGiven  "simple1.ipynb")
     let ipynb2 = File.ReadAllText(rootOutputFolderAsGiven  "simple2.ipynb")
     ipynb1 |> shouldContainText "simple2.ipynb"
     ipynb2 |> shouldContainText "simple1.ipynb"
 
     // Check fsx exists
+    // Check simple1.fsx --> simple1.fsx substititions
+    // Check simple2.md --> simple1.fsx substititions
     let fsx1 = File.ReadAllText(rootOutputFolderAsGiven  "simple1.fsx")
     let fsx2 = File.ReadAllText(rootOutputFolderAsGiven  "simple2.fsx")
     fsx1 |> shouldContainText "simple2.fsx"
     fsx2 |> shouldContainText "simple1.fsx"
 
     // Check md contents
+    // Check simple1.fsx --> simple1.md substititions
+    // Check simple2.md --> simple1.md substititions
+    let md1 = File.ReadAllText(rootOutputFolderAsGiven  "simple1.md")
+    let md2 = File.ReadAllText(rootOutputFolderAsGiven  "simple2.md")
+    md1 |> shouldContainText "simple2.md"
+    md2 |> shouldContainText "simple1.md"
+
+
+    // Check in-folder1.fsx --> in-folder1.html substititions
+    let f1html1 = File.ReadAllText(rootOutputFolderAsGiven  "folder1"  "in-folder1.html")
+    let f2html2 = File.ReadAllText(rootOutputFolderAsGiven  "folder2"  "in-folder2.html")
+    f1html1 |> shouldContainText """href="../folder2/in-folder2.html">"""
+    f2html2 |> shouldContainText """href="../folder1/in-folder1.html">"""
+
+    // Check in-folder1.fsx --> in-folder1.ipynb substititions
+    let f1ipynb1 = File.ReadAllText(rootOutputFolderAsGiven  "folder1"  "in-folder1.ipynb")
+    let f2ipynb2 = File.ReadAllText(rootOutputFolderAsGiven  "folder2"  "in-folder2.ipynb")
+    f1ipynb1 |> shouldContainText """../folder2/in-folder2.ipynb"""
+    f2ipynb2 |> shouldContainText """../folder1/in-folder1.ipynb"""
+
+    // Check fsx exists
+    let f1fsx1 = File.ReadAllText(rootOutputFolderAsGiven  "folder1"  "in-folder1.fsx")
+    let f2fsx2 = File.ReadAllText(rootOutputFolderAsGiven  "folder2"  "in-folder2.fsx")
+    f1fsx1 |> shouldContainText """../folder2/in-folder2.fsx"""
+    f2fsx2 |> shouldContainText """../folder1/in-folder1.fsx"""
+
+    // Check md contents
+    let f1md1 = File.ReadAllText(rootOutputFolderAsGiven  "folder1"  "in-folder1.md")
+    let f2md2 = File.ReadAllText(rootOutputFolderAsGiven  "folder2"  "in-folder2.md")
+    f1md1 |> shouldContainText """../folder2/in-folder2.md"""
+    f2md2 |> shouldContainText """../folder1/in-folder1.md"""
+
+
+// Same as above with relative input folder
+[]
+let ``Can build doc content using relative input path`` () =
+    let rootOutputFolderAsGiven = __SOURCE_DIRECTORY__  "output1"
+
+    let relativeInputFolderAsGiven =
+        Path.GetRelativePath(System.Environment.CurrentDirectory, __SOURCE_DIRECTORY__  "files")
+
+    if Directory.Exists(rootOutputFolderAsGiven) then
+        Directory.Delete(rootOutputFolderAsGiven, true)
+
+    let content =
+        DocContent(
+            rootOutputFolderAsGiven,
+            Map.empty,
+            lineNumbers = None,
+            fsiEvaluator = None,
+            substitutions = [],
+            saveImages = None,
+            watch = false,
+            root = "https://github.com",
+            crefResolver = (fun _ -> None),
+            onError = failwith
+        )
+
+    let docModels = content.Convert(relativeInputFolderAsGiven, None, [])
+    let globals = []
+
+    for (_thing, action) in docModels do
+        action globals
+
+    // Check simple1.fsx --> simple1.html substititions
+    // Check simple2.md --> simple2.html substititions
+    let html1 = File.ReadAllText(rootOutputFolderAsGiven  "simple1.html")
+    let html2 = File.ReadAllText(rootOutputFolderAsGiven  "simple2.html")
+    html1 |> shouldContainText """href="simple1.html">"""
+    html1 |> shouldContainText """href="simple2.html">"""
+    html2 |> shouldContainText """href="simple1.html">"""
+    html2 |> shouldContainText """href="simple2.html">"""
+
+    // Check simple1.fsx --> simple1.ipynb substititions
+    // Check simple2.md --> simple1.ipynb substititions
+    let ipynb1 = File.ReadAllText(rootOutputFolderAsGiven  "simple1.ipynb")
+    let ipynb2 = File.ReadAllText(rootOutputFolderAsGiven  "simple2.ipynb")
+    ipynb1 |> shouldContainText "simple2.ipynb"
+    ipynb2 |> shouldContainText "simple1.ipynb"
+
+    // Check fsx exists
+    // Check simple1.fsx --> simple1.fsx substititions
+    // Check simple2.md --> simple1.fsx substititions
+    let fsx1 = File.ReadAllText(rootOutputFolderAsGiven  "simple1.fsx")
+    let fsx2 = File.ReadAllText(rootOutputFolderAsGiven  "simple2.fsx")
+    fsx1 |> shouldContainText "simple2.fsx"
+    fsx2 |> shouldContainText "simple1.fsx"
+
+    // Check md contents
+    // Check simple1.fsx --> simple1.md substititions
+    // Check simple2.md --> simple1.md substititions
     let md1 = File.ReadAllText(rootOutputFolderAsGiven  "simple1.md")
     let md2 = File.ReadAllText(rootOutputFolderAsGiven  "simple2.md")
     md1 |> shouldContainText "simple2.md"
diff --git a/tests/FSharp.Literate.Tests/files/simple1.fsx b/tests/FSharp.Literate.Tests/files/simple1.fsx
index 600772faf..5b5382c62 100644
--- a/tests/FSharp.Literate.Tests/files/simple1.fsx
+++ b/tests/FSharp.Literate.Tests/files/simple1.fsx
@@ -11,6 +11,7 @@ substitute-in-markdown: {{fsdocs-source-basename}}
 [ABC](http://substitute-in-link: {{fsdocs-source-basename}})
 [substitute-in-href-text: {{fsdocs-source-basename}}](http://google.com)
 
+Another [hyperlink](simple1.fsx)
 Another [hyperlink](simple2.md)
 
 *)
diff --git a/tests/FSharp.Literate.Tests/files/simple2.md b/tests/FSharp.Literate.Tests/files/simple2.md
index 2cc166c08..f59ee8d0c 100644
--- a/tests/FSharp.Literate.Tests/files/simple2.md
+++ b/tests/FSharp.Literate.Tests/files/simple2.md
@@ -6,3 +6,4 @@ With some [hyperlink](http://tomasp.net)
     let hello = "Code sample"
 
 Another [hyperlink](simple1.fsx)
+Yet another [hyperlink](simple2.md)