Skip to content

Commit 6d6e97f

Browse files
authored
Merge pull request #946 from baronfel/docs-url-fixes
set the root url to be scheme-less for local dev, and fix api reference urls to the way they used to be
2 parents dfa6d33 + 8af36a1 commit 6d6e97f

File tree

7 files changed

+108
-121
lines changed

7 files changed

+108
-121
lines changed

fcs/docsrc/generators/apiref.fsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -258,24 +258,21 @@ let generateNamespace ctx (n: Namespace) =
258258

259259

260260
let generate' (ctx : SiteContents) =
261-
let all = ctx.TryGetValues<AssemblyEntities>()
261+
let all = ctx.TryGetValue<AssemblyEntities>()
262262
match all with
263263
| None -> []
264-
| Some all ->
265-
all
266-
|> Seq.toList
267-
|> List.collect (fun n ->
268-
let name = n.GeneratorOutput.AssemblyGroup.Name
264+
| Some assyEntities ->
265+
let name = assyEntities.GeneratorOutput.AssemblyGroup.Name
269266
let namespaces =
270-
n.GeneratorOutput.AssemblyGroup.Namespaces
267+
assyEntities.GeneratorOutput.AssemblyGroup.Namespaces
271268
|> List.map (generateNamespace ctx)
272269

273270
let modules =
274-
n.Modules
271+
assyEntities.Modules
275272
|> Seq.map (generateModule ctx)
276273

277274
let types =
278-
n.Types
275+
assyEntities.Types
279276
|> Seq.map (generateType ctx)
280277

281278
let ref =
@@ -286,11 +283,9 @@ let generate' (ctx : SiteContents) =
286283
for (n, _) in namespaces do
287284
a [Href (sprintf "%s.html" n)] [!!n]
288285
br []
289-
] n.Label
286+
] assyEntities.Label
290287

291288
[("index" , ref); yield! namespaces; yield! modules; yield! types]
292-
|> List.map (fun (x, y) -> (sprintf "%s/%s" n.Label x), y)
293-
)
294289

295290

296291
let generate (ctx : SiteContents) (projectRoot: string) (page: string) =

fcs/docsrc/generators/lunr.fsx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,22 @@ let generate (ctx : SiteContents) (projectRoot: string) (page: string) =
2727
let entries =
2828
pages
2929
|> Seq.map (fun n ->
30-
{uri = rootUrl + "/" + n.link.Replace("content/", ""); title = n.title; content = n.text}
30+
{uri = rootUrl.subRoute (n.link.Replace("content/", "")); title = n.title; content = n.text}
3131
)
3232

33-
let all = ctx.TryGetValues<AssemblyEntities>()
33+
let all = ctx.TryGetValue<AssemblyEntities>()
3434
let refs =
3535
match all with
3636
| None -> []
37-
| Some all ->
38-
all
39-
|> Seq.toList
40-
|> List.collect (fun n ->
41-
let generatorOutput = n.GeneratorOutput
42-
let allModules = n.Modules
43-
let allTypes = n.Types
37+
| Some assembyEntities ->
38+
let generatorOutput = assembyEntities.GeneratorOutput
39+
let allModules = assembyEntities.Modules
40+
let allTypes = assembyEntities.Types
4441

4542
let gen =
4643
let ctn =
4744
sprintf "%s \n %s" generatorOutput.AssemblyGroup.Name (generatorOutput.AssemblyGroup.Namespaces |> Seq.map (fun n -> n.Name) |> String.concat " ")
48-
{uri = (rootUrl + sprintf "/reference/%s/index.html" n.Label ); title = sprintf "%s - API Reference" n.Label; content = ctn }
45+
{uri = (rootUrl.subRoute "/reference/index.html"); title = sprintf "%s - API Reference" assembyEntities.Label; content = ctn }
4946

5047
let mdlsGen =
5148
allModules
@@ -61,7 +58,7 @@ let generate (ctx : SiteContents) (projectRoot: string) (page: string) =
6158
(m.TypeExtensions |> List.map (fun m -> m.Name + " " + m.Comment.FullText ) |> String.concat " ")
6259

6360

64-
{uri = rootUrl + sprintf "/reference/%s/%s.html" n.Label m.UrlName ; title = m.Name; content = cnt }
61+
{uri = rootUrl.subRoutef "/reference/%s.html" m.UrlName ; title = m.Name; content = cnt }
6562
)
6663

6764
let tsGen =
@@ -75,10 +72,10 @@ let generate (ctx : SiteContents) (projectRoot: string) (page: string) =
7572
(m.AllMembers |> List.map (fun m -> m.Name + " " + m.Comment.FullText ) |> String.concat " ")
7673

7774

78-
{uri = rootUrl + sprintf "/reference/%s/%s.html" n.Label m.UrlName ; title = m.Name; content = cnt }
75+
{uri = rootUrl.subRoutef "/reference/%s.html" m.UrlName ; title = m.Name; content = cnt }
7976
)
8077
[yield! entries; gen; yield! mdlsGen; yield! tsGen]
81-
)
78+
8279
printfn "generated search index"
8380
[|yield! entries; yield! refs|]
8481
|> Newtonsoft.Json.JsonConvert.SerializeObject

fcs/docsrc/generators/partials/footer.fsx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,21 @@ let footer (ctx : SiteContents) =
1717
div [Custom("style", "left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;")] [
1818
div [Custom("style", "border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;")] []
1919
]
20-
script [Src (rootUrl + "/static/js/clipboard.min.js")] []
21-
script [Src (rootUrl + "/static/js/perfect-scrollbar.min.js")] []
22-
script [Src (rootUrl + "/static/js/perfect-scrollbar.jquery.min.js")] []
23-
script [Src (rootUrl + "/static/js/jquery.sticky.js")] []
24-
script [Src (rootUrl + "/static/js/featherlight.min.js")] []
25-
26-
script [Src (rootUrl + "/static/js/modernizr.custom-3.6.0.js")] []
27-
script [Src (rootUrl + "/static/js/learn.js")] []
28-
script [Src (rootUrl + "/static/js/hugo-learn.js")] []
29-
link [Rel "stylesheet"; Href (rootUrl + "/static/mermaid/mermaid.css")]
30-
script [Src (rootUrl + "/static/mermaid/mermaid.js")] []
20+
script [Src (rootUrl.subRoute "/static/js/clipboard.min.js")] []
21+
script [Src (rootUrl.subRoute "/static/js/perfect-scrollbar.min.js")] []
22+
script [Src (rootUrl.subRoute "/static/js/perfect-scrollbar.jquery.min.js")] []
23+
script [Src (rootUrl.subRoute "/static/js/jquery.sticky.js")] []
24+
script [Src (rootUrl.subRoute "/static/js/featherlight.min.js")] []
25+
script [Src (rootUrl.subRoute "/static/js/modernizr.custom-3.6.0.js")] []
26+
script [Src (rootUrl.subRoute "/static/js/learn.js")] []
27+
script [Src (rootUrl.subRoute "/static/js/hugo-learn.js")] []
28+
link [Rel "stylesheet"; Href (rootUrl.subRoute "/static/mermaid/mermaid.css")]
29+
script [Src (rootUrl.subRoute "/static/mermaid/mermaid.js")] []
3130
script [] [!! "mermaid.initialize({ startOnLoad: true });"]
32-
script [Src "//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/highlight.min.js"] []
33-
script [Src "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/fsharp.min.js"] []
31+
script [Src "////cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/highlight.min.js"] []
32+
script [Src "//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/fsharp.min.js"] []
3433
script [] [
3534
!! "hljs.initHighlightingOnLoad()"
3635
]
37-
script [Src (rootUrl + "/static/js/tips.js")] []
36+
script [Src (rootUrl.subRoute "/static/js/tips.js")] []
3837
]

fcs/docsrc/generators/partials/header.fsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,17 @@ let header (ctx : SiteContents) page =
1515
meta [CharSet "utf-8"]
1616
meta [Name "viewport"; Content "width=device-width, initial-scale=1"]
1717
title [] [!! (siteInfo.title + " | " + page)]
18-
link [Rel "icon"; Type "image/png"; Sizes "32x32"; Href (rootUrl + "/static/images/favicon.png")]
19-
link [Rel "stylesheet"; Href (rootUrl + "/static/css/nucleus.css")]
20-
link [Rel "stylesheet"; Href (rootUrl + "/static/css/fontawesome-all.min.css")]
21-
link [Rel "stylesheet"; Href (rootUrl + "/static/css/hybrid.css")]
22-
link [Rel "stylesheet"; Href (rootUrl + "/static/css/featherlight.min.css")]
23-
link [Rel "stylesheet"; Href (rootUrl + "/static/css/perfect-scrollbar.min.css")]
24-
link [Rel "stylesheet"; Href (rootUrl + "/static/css/auto-complete.css")]
25-
link [Rel "stylesheet"; Href (rootUrl + "/static/css/atom-one-dark-reasonable.css")]
26-
link [Rel "stylesheet"; Href (rootUrl + "/static/css/theme.css")]
27-
link [Rel "stylesheet"; Href (rootUrl + "/static/css/tips.css")]
18+
link [Rel "icon"; Type "image/png"; Sizes "32x32"; Href (rootUrl.subRoute "/static/images/favicon.png")]
19+
link [Rel "stylesheet"; Href (rootUrl.subRoute "/static/css/nucleus.css")]
20+
link [Rel "stylesheet"; Href (rootUrl.subRoute "/static/css/fontawesome-all.min.css")]
21+
link [Rel "stylesheet"; Href (rootUrl.subRoute "/static/css/hybrid.css")]
22+
link [Rel "stylesheet"; Href (rootUrl.subRoute "/static/css/featherlight.min.css")]
23+
link [Rel "stylesheet"; Href (rootUrl.subRoute "/static/css/perfect-scrollbar.min.css")]
24+
link [Rel "stylesheet"; Href (rootUrl.subRoute "/static/css/auto-complete.css")]
25+
link [Rel "stylesheet"; Href (rootUrl.subRoute "/static/css/atom-one-dark-reasonable.css")]
26+
link [Rel "stylesheet"; Href (rootUrl.subRoute "/static/css/theme.css")]
27+
link [Rel "stylesheet"; Href (rootUrl.subRoute "/static/css/tips.css")]
2828
link [Rel "stylesheet"; Href "//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/styles/atom-one-dark.min.css"]
29-
if siteInfo.theme_variant.IsSome then
30-
link [Rel "stylesheet"; Href (rootUrl + (sprintf "/static/css/theme-%s.css" siteInfo.theme_variant.Value))]
31-
script [Src (rootUrl + "/static/js/jquery-3.3.1.min.js")] []
29+
link [Rel "stylesheet"; Href (rootUrl.subRoutef "/static/css/theme-%s.css" ((siteInfo.theme_variant.ToString().ToLower()))) ]
30+
script [Src (rootUrl.subRoute "/static/js/jquery-3.3.1.min.js")] []
3231
]

fcs/docsrc/generators/partials/menu.fsx

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ open Html
1111

1212
let menu (ctx : SiteContents) (page: string) =
1313
let shortcuts = ctx.GetValues<Pageloader.Shortcut> ()
14-
let all = ctx.GetValues<Apirefloader.AssemblyEntities>()
14+
let apiRef = ctx.TryGetValue<Apirefloader.AssemblyEntities>()
1515

1616
let content = ctx.GetValues<Contentloader.Post> ()
1717
let siteInfo = ctx.TryGetValue<Globalloader.SiteInfo>().Value
@@ -24,7 +24,7 @@ let menu (ctx : SiteContents) (page: string) =
2424

2525
let group = content |> Seq.tryFind (fun n -> n.title = page) |> Option.map (fun n -> n.category)
2626

27-
let explenations =
27+
let explanations =
2828
content
2929
|> Seq.filter (fun n -> n.category = Contentloader.Explanation && not n.hide_menu && n.language = language )
3030
|> Seq.sortBy (fun n -> n.menu_order)
@@ -40,12 +40,12 @@ let menu (ctx : SiteContents) (page: string) =
4040
|> Seq.sortBy (fun n -> n.menu_order)
4141

4242
let hasTutorials = not (Seq.isEmpty tutorials)
43-
let hasExplenations = not (Seq.isEmpty explenations)
43+
let hasExplanations = not (Seq.isEmpty explanations)
4444
let hasHowTos = not (Seq.isEmpty howtos)
4545

4646
let menuHeader =
4747
[
48-
if hasExplenations then
48+
if hasExplanations then
4949
li [Id "menu-explanations"; if group = Some Contentloader.Explanation then Class "dd-item menu-group-link menu-group-link-active" else Class "dd-item menu-group-link"; ] [
5050
a [] [!! "Explanation"]
5151
]
@@ -58,15 +58,15 @@ let menu (ctx : SiteContents) (page: string) =
5858
a [] [!! "How-To Guides"]
5959
]
6060
li [ Id "menu-refs"; if group = None then Class "dd-item menu-group-link menu-group-link-active" else Class "dd-item menu-group-link";] [
61-
a [] [!! "API References"]
61+
a [Href (rootUrl.subRoute "/reference/index.html")] [!! "API Reference"]
6262
]
6363
]
6464

6565
let renderExpls =
6666
ul [Id "submenu-explanations"; if group = Some Contentloader.Explanation then Class "submenu submenu-active" else Class "submenu"; ] [
67-
for r in explenations ->
67+
for r in explanations ->
6868
li [] [
69-
a [Href (rootUrl + "/" + r.link); if r.title = page then Class "active-link padding" else Class "padding"] [
69+
a [Href (rootUrl.subRoute r.link); if r.title = page then Class "active-link padding" else Class "padding"] [
7070
!! r.title
7171
]
7272
]
@@ -76,7 +76,7 @@ let menu (ctx : SiteContents) (page: string) =
7676
ul [Id "submenu-tutorials"; if group = Some Contentloader.Tutorial then Class "submenu submenu-active" else Class "submenu"; ] [
7777
for r in tutorials ->
7878
li [] [
79-
a [ Href (rootUrl + "/" + r.link); if r.title = page then Class "active-link padding" else Class "padding" ] [
79+
a [ Href (rootUrl.subRoute r.link); if r.title = page then Class "active-link padding" else Class "padding" ] [
8080
!! r.title
8181
]
8282
]
@@ -86,33 +86,23 @@ let menu (ctx : SiteContents) (page: string) =
8686
ul [Id "submenu-howtos"; if group = Some Contentloader.HowTo then Class "submenu submenu-active" else Class "submenu"; ] [
8787
for r in howtos ->
8888
li [] [
89-
a [Href (rootUrl + "/" + r.link); if r.title = page then Class "active-link padding" else Class "padding" ] [
89+
a [Href (rootUrl.subRoute r.link); if r.title = page then Class "active-link padding" else Class "padding" ] [
9090
!! r.title
9191
]
9292
]
9393
]
9494

95-
let renderRefs =
96-
ul [Id "submenu-refs"; if group = None then Class "submenu submenu-active" else Class "submenu"; ] [
97-
for r in all ->
98-
li [] [
99-
a [Href (rootUrl + "/reference/" + r.Label + "/index.html"); if r.Label = page then Class "active-link padding" else Class "padding" ] [
100-
!! r.Label
101-
]
102-
]
103-
]
104-
10595
let renderLanguages =
10696
section [Id "languages"] [
10797
h3 [] [!! "Languages"]
10898
ul [] [
10999
li [] [
110-
a [Href (rootUrl + "/index.html"); if language = None then Class "menu-group-link-active padding" else Class "padding" ] [
100+
a [Href (rootUrl.subRoute "/index.html"); if language = None then Class "menu-group-link-active padding" else Class "padding" ] [
111101
!! "English"
112102
]
113103
]
114104
li [] [
115-
a [Href (rootUrl + "/ja/index.html"); if language = Some "ja" then Class "menu-group-link-active padding" else Class "padding" ] [
105+
a [Href (rootUrl.subRoute "/ja/index.html"); if language = Some "ja" then Class "menu-group-link-active padding" else Class "padding" ] [
116106
!! "Japanese"
117107
]
118108
]
@@ -121,7 +111,7 @@ let menu (ctx : SiteContents) (page: string) =
121111

122112
let renderShortucuts =
123113
section [Id "shortcuts"] [
124-
h3 [] [!! "Shortucts"]
114+
h3 [] [!! "Shortcuts"]
125115
ul [] [
126116
for s in shortcuts do
127117
yield
@@ -150,17 +140,16 @@ let menu (ctx : SiteContents) (page: string) =
150140
input [Custom ("data-search-input", ""); Id "search-by"; Type "search"; Placeholder "Search..."]
151141
span [Custom ("data-search-clear", "")] [i [Class "fas fa-times"] []]
152142
]
153-
script [Type "text/javascript"; Src (rootUrl + "/static/js/lunr.min.js")] []
154-
script [Type "text/javascript"; Src (rootUrl + "/static/js/auto-complete.js")] []
155-
script [Type "text/javascript";] [!! (sprintf "var baseurl ='%s'" rootUrl)]
156-
script [Type "text/javascript"; Src (rootUrl + "/static/js/search.js")] []
143+
script [Type "text/javascript"; Src (rootUrl.subRoute "/static/js/lunr.min.js")] []
144+
script [Type "text/javascript"; Src (rootUrl.subRoute "/static/js/auto-complete.js")] []
145+
script [Type "text/javascript";] [!! (sprintf "var baseurl ='%s'" (rootUrl.subRoute "")) ]
146+
script [Type "text/javascript"; Src (rootUrl.subRoute "/static/js/search.js")] []
157147
]
158148
div [Class "highlightable"] [
159149
ul [Class "topics"] menuHeader
160-
if hasExplenations then renderExpls
150+
if hasExplanations then renderExpls
161151
if hasTutorials then renderTuts
162152
if hasHowTos then renderHowTos
163-
renderRefs
164153
renderLanguages
165154
renderShortucuts
166155
renderFooter

fcs/docsrc/loaders/apirefloader.fsx

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,44 +29,40 @@ let rec collectModules pn pu nn nu (m: Module) =
2929

3030
let loader (projectRoot: string) (siteContent: SiteContents) =
3131
try
32-
let dlls =
33-
[
34-
"FSharp.Compiler.Service", Path.Combine(projectRoot, "..", "..", "artifacts", "bin", "fcs", "Release", "netcoreapp3.0", "FSharp.Compiler.Service.dll")
35-
]
36-
let libs =
37-
[
38-
Path.Combine(projectRoot, "..", "..", "artifacts", "bin", "fcs", "Release", "netcoreapp3.0")
39-
]
40-
for (label, dll) in dlls do
41-
printfn "generating api ref for %s at %s" label dll
32+
let label = "FSharp.Compiler.Service"
33+
let dll = Path.Combine(projectRoot, "..", "..", "artifacts", "bin", "fcs", "Release", "netcoreapp3.0", "FSharp.Compiler.Service.dll")
34+
let libs = Path.Combine(projectRoot, "..", "..", "artifacts", "bin", "fcs", "Release", "netcoreapp3.0")
4235

43-
let output = MetadataFormat.Generate(dll, markDownComments = true, publicOnly = true, libDirs = libs)
36+
printfn "generating api ref for %s at %s" label dll
4437

45-
let allModules =
46-
output.AssemblyGroup.Namespaces
47-
|> List.collect (fun n ->
48-
List.collect (collectModules n.Name n.Name n.Name n.Name) n.Modules
49-
)
38+
let output = MetadataFormat.Generate(dll, markDownComments = true, publicOnly = true, libDirs = [libs])
5039

51-
let allTypes =
52-
[
53-
yield!
54-
output.AssemblyGroup.Namespaces
55-
|> List.collect (fun n ->
56-
n.Types |> List.map (fun t -> {ParentName = n.Name; ParentUrlName = n.Name; NamespaceName = n.Name; NamespaceUrlName = n.Name; Info = t} )
57-
)
58-
yield!
59-
allModules
60-
|> List.collect (fun n ->
61-
n.Info.NestedTypes |> List.map (fun t -> {ParentName = n.Info.Name; ParentUrlName = n.Info.UrlName; NamespaceName = n.NamespaceName; NamespaceUrlName = n.NamespaceUrlName; Info = t}) )
62-
]
63-
let entities = {
64-
Label = label
65-
Modules = allModules
66-
Types = allTypes
67-
GeneratorOutput = output
68-
}
69-
siteContent.Add entities
40+
let allModules =
41+
output.AssemblyGroup.Namespaces
42+
|> List.collect (fun n ->
43+
List.collect (collectModules n.Name n.Name n.Name n.Name) n.Modules
44+
)
45+
46+
let allTypes =
47+
[
48+
yield!
49+
output.AssemblyGroup.Namespaces
50+
|> List.collect (fun n ->
51+
n.Types |> List.map (fun t -> {ParentName = n.Name; ParentUrlName = n.Name; NamespaceName = n.Name; NamespaceUrlName = n.Name; Info = t} )
52+
)
53+
yield!
54+
allModules
55+
|> List.collect (fun n ->
56+
n.Info.NestedTypes |> List.map (fun t -> {ParentName = n.Info.Name; ParentUrlName = n.Info.UrlName; NamespaceName = n.NamespaceName; NamespaceUrlName = n.NamespaceUrlName; Info = t}) )
57+
]
58+
let entities = {
59+
Label = label
60+
Modules = allModules
61+
Types = allTypes
62+
GeneratorOutput = output
63+
}
64+
siteContent.Add entities
65+
printfn "generated api ref for %s at %s" label dll
7066
with
7167
| ex ->
7268
printfn "%A" ex

0 commit comments

Comments
 (0)