-
Notifications
You must be signed in to change notification settings - Fork 44
/
post-process-docs.m
73 lines (65 loc) · 2.38 KB
/
post-process-docs.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
(* Mathematica Source File *)
(* Created by Mathematica Plugin for IntelliJ IDEA *)
(* :Author: szhorvat *)
(* :Date: 2016-11-28 *)
(* Run this script optionally for minor improvements to the built documentation.
Requires PackageTools, https://github.com/szhorvat/PackageTools
*)
AddPath["PackageTools"]
Needs["PackageTools`"]
SetDirectory@DirectoryName[$InputFileName]
$appName = "MaTeX";
$docDir = FileNameJoin[{"build", $appName, "Documentation"}];
If[Not@DirectoryQ[$docDir],
Print["Documentation directory not found. Aborting."];
Abort[]
]
code =
With[{$docDir = $docDir, $appName = $appName},
MCode[
echo = (Print[#];#)&;
FileNames["*.nb", $docDir, Infinity] //
Scan[
echo /*
RewriteNotebook[
NBHideInput /*
NBRemoveURL /*
NBDeleteCellTags["HideInput"] /*
NBSetOptions[Saveable -> False] /*
NBRemoveChangeTimes /*
NBResetWindow /*
Function[nb,
Replace[nb, sd : HoldPattern[StyleDefinitions -> Except[_Notebook]] :>
StyleDefinitions -> Notebook[{Cell@StyleData[sd]}],
{1}
]
] /*
Function[nb,
Replace[nb,
HoldPattern[StyleDefinitions -> Notebook[{cells___}, rest___]] :>
(StyleDefinitions -> Notebook[
{
cells,
Cell[StyleData[#], ShowGroupOpener -> True]& /@ Unevaluated@Sequence["NotesSection", "PrimaryExamplesSection", "ExampleSection", "ExampleSubsection"],
Cell[StyleData["GuideTutorialsSection", StyleDefinitions -> StyleData["SeeAlsoSection"]]]
}, rest]),
{1}
]
] /*
Function[nb,
Replace[nb,
(BaseStyle->{"InlineFormula", FontFamily -> "Verdana"}) ->
(BaseStyle -> FEPrivate`If[
FEPrivate`Less[ FEPrivate`$VersionNumber, 11.1],
{"InlineFormula", FontFamily -> "Verdana"},
{"InlineFormula"}
]),
Infinity
]
]
]
]
]
];
(* Process in version 10.0 to avoid InsufficientVersionWarning *)
MRun[code, "10.0"]