Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 762b4ce

Browse files
authored
Merge pull request #23 from fsharp/use-new-index
use index generated from F#F
2 parents acbb4e5 + ad6166d commit 762b4ce

File tree

1 file changed

+10
-64
lines changed

1 file changed

+10
-64
lines changed

generators/lunr.fsx

Lines changed: 10 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -10,73 +10,19 @@
1010
open Apirefloader
1111
open FSharp.Formatting.ApiDocs
1212

13-
type Entry = {
14-
uri: string
15-
title: string
16-
content: string
17-
}
18-
19-
let stripMicrosoft (str: string) =
20-
if str.StartsWith("Microsoft.") then
21-
str.["Microsoft.".Length ..]
22-
elif str.StartsWith("microsoft-") then
23-
str.["microsoft-".Length ..]
24-
else
25-
str
26-
2713
let generate (ctx : SiteContents) (projectRoot: string) (page: string) =
28-
let siteInfo = ctx.TryGetValue<Globalloader.SiteInfo>().Value
29-
let rootUrl = siteInfo.root_url
3014
let all = ctx.TryGetValues<AssemblyEntities>()
3115
let refs =
3216
match all with
33-
| None -> []
17+
| None -> [| |]
3418
| Some all ->
35-
all
36-
|> Seq.toList
37-
|> List.collect (fun n ->
38-
let generatorOutput = n.GeneratorOutput
39-
let allModules = n.Modules
40-
let allTypes = n.Types
41-
42-
let gen =
43-
let ctn =
44-
sprintf "%s \n %s" generatorOutput.AssemblyGroup.Name (generatorOutput.AssemblyGroup.Namespaces |> Seq.map (fun n -> n.Name) |> String.concat " ")
45-
{uri = (rootUrl + sprintf "/reference/%s/index.html" n.Label ); title = sprintf "%s - API Reference" n.Label; content = ctn }
46-
47-
let mdlsGen =
48-
allModules
49-
|> Seq.map (fun m ->
50-
let m = m.Info
51-
let cnt =
52-
sprintf "%s \n %s \n %s \n %s \n %s \n %s"
53-
m.Name
54-
m.Comment.FullText
55-
(m.NestedModules |> List.map (fun m -> m.Name + " " + m.Comment.FullText ) |> String.concat " ")
56-
(m.NestedTypes |> List.map (fun m -> m.Name + " " + m.Comment.FullText ) |> String.concat " ")
57-
(m.ValuesAndFuncs |> List.map (fun m -> m.Name + " " + m.Comment.FullText ) |> String.concat " ")
58-
(m.TypeExtensions |> List.map (fun m -> m.Name + " " + m.Comment.FullText ) |> String.concat " ")
59-
60-
61-
{uri = rootUrl + sprintf "/reference/%s/%s.html" n.Label (stripMicrosoft m.UrlBaseName) ; title = m.Name; content = cnt }
62-
)
63-
64-
let tsGen =
65-
allTypes
66-
|> Seq.map (fun m ->
67-
let m = m.Info
68-
let cnt =
69-
sprintf "%s \n %s \n %s"
70-
m.Name
71-
m.Comment.FullText
72-
(m.AllMembers |> List.map (fun m -> m.Name + " " + m.Comment.FullText ) |> String.concat " ")
73-
74-
75-
{uri = rootUrl + sprintf "/reference/%s/%s.html" n.Label m.UrlBaseName ; title = m.Name; content = cnt }
76-
)
77-
[gen; yield! mdlsGen; yield! tsGen]
78-
)
79-
80-
[|yield! refs|]
19+
match List.ofSeq all with
20+
| [model] ->
21+
let model = { model.GeneratorOutput with
22+
CollectionRootUrl = "/reference/FSharp.Core" }
23+
ApiDocs.GenerateSearchIndexFromModel model
24+
| _ ->
25+
[| |]
26+
27+
refs
8128
|> Newtonsoft.Json.JsonConvert.SerializeObject
82-

0 commit comments

Comments
 (0)