Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add classes to the odoc HTML page structure. #589

Merged
merged 2 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/html/generator.ml
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ module Toc = struct
in
match toc with
| [] -> []
| _ -> [ Html.nav ~a:[ Html.a_class [ "toc" ] ] [ sections toc ] ]
| _ -> [ Html.nav ~a:[ Html.a_class [ "odoc-toc" ] ] [ sections toc ] ]

let on_sub : Subpage.status -> bool = function
| `Closed | `Open | `Default -> false
Expand Down
9 changes: 5 additions & 4 deletions src/html/tree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,16 @@ let page_creator ?(theme_uri = Relative "./") ~url name header toc content =
else [ [ Html.txt lbl ] ])
|> List.flatten
in
[ Html.nav l ]
[ Html.nav ~a:[ Html.a_class [ "odoc-nav" ] ] l ]
else []
in

let body =
breadcrumbs @ [ Html.header header ] @ toc
@ [ Html.div ~a:[ Html.a_class [ "content" ] ] content ]
breadcrumbs @ [ Html.header ~a:[ Html.a_class [ "odoc-preamble" ] ] header ]
@ toc
@ [ Html.div ~a:[ Html.a_class [ "odoc-content" ] ] content ]
in
Html.html head (Html.body body)
Html.html head (Html.body ~a:[ Html.a_class [ "odoc" ] ] body)

let make ?theme_uri ~indent ~url ~header ~toc title content children =
let filename = Link.Path.as_filename url in
Expand Down
24 changes: 12 additions & 12 deletions src/odoc/etc/odoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ h1+.modules, h1+.sel {

/* Sidebar and TOC */

.toc:before {
.odoc-toc:before {
display: block;
content: "Contents";
text-transform: uppercase;
Expand All @@ -701,7 +701,7 @@ h1+.modules, h1+.sel {
line-height: 1.2;
}

.toc {
.odoc-toc {
position: fixed;
top: 0px;
bottom: 0px;
Expand All @@ -718,7 +718,7 @@ h1+.modules, h1+.sel {
padding-right: 2ex;
}

.toc ul li a {
.odoc-toc ul li a {
font-family: "Fira Sans", sans-serif;
font-size: 0.95em;
color: #333;
Expand All @@ -728,33 +728,33 @@ h1+.modules, h1+.sel {
display: block;
}

.toc ul li a:hover {
.odoc-toc ul li a:hover {
box-shadow: none;
text-decoration: underline;
}

/* First level titles */

.toc>ul>li>a {
.odoc-toc>ul>li>a {
font-weight: 500;
}

.toc li ul {
.odoc-toc li ul {
margin: 0px;
}

.toc ul {
.odoc-toc ul {
list-style-type: none;
}

.toc ul li {
.odoc-toc ul li {
margin: 0;
}
.toc>ul>li {
.odoc-toc>ul>li {
margin-bottom: 0.3em;
}

.toc ul li li {
.odoc-toc ul li li {
border-left: 1px solid #ccc;
border-left: 1px solid var(--toc-list-border);
margin-left: 5px;
Expand All @@ -764,11 +764,11 @@ h1+.modules, h1+.sel {
/* Mobile adjustements. */

@media only screen and (max-width: 95ex) {
.content {
.odoc-content {
margin: auto;
padding: 2em;
}
.toc {
.odoc-toc {
position: static;
width: auto;
min-width: unset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<nav>
<body class="odoc">
<nav class="odoc-nav">
<a href="../index.html">Up</a> – <a href="../index.html">test_package+custom_theme,ml</a> » Include
</nav>
<header>
<header class="odoc-preamble">
<h1>
Module <code>Include</code>
</h1>
</header>
<div class="content">
<div class="odoc-content">
<div class="spec module-type" id="module-type-Not_inlined">
<a href="#module-type-Not_inlined" class="anchor"></a><code><span class="keyword">module</span> <span class="keyword">type</span> <a href="module-type-Not_inlined/index.html">Not_inlined</a> = <span class="keyword">sig</span> ... <span class="keyword">end</span></code>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<nav>
<body class="odoc">
<nav class="odoc-nav">
<a href="../index.html">Up</a> – <a href="../index.html">test_package+custom_theme,ml</a> » Module
</nav>
<header>
<header class="odoc-preamble">
<h1>
Module <code>Module</code>
</h1>
<p>
Foo.
</p>
</header>
<div class="content">
<div class="odoc-content">
<div>
<div class="spec value" id="val-foo">
<a href="#val-foo" class="anchor"></a><code><span class="keyword">val</span> foo : unit</code>
Expand Down
10 changes: 5 additions & 5 deletions test/html/expect/test_package+custom_theme,ml/Section/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<nav>
<body class="odoc">
<nav class="odoc-nav">
<a href="../index.html">Up</a> – <a href="../index.html">test_package+custom_theme,ml</a> » Section
</nav>
<header>
<header class="odoc-preamble">
<h1>
Module <code>Section</code>
</h1>
<p>
This is the module comment. Eventually, sections won't be allowed in it.
</p>
</header>
<nav class="toc">
<nav class="odoc-toc">
<ul>
<li>
<a href="#empty-section">Empty section</a>
Expand Down Expand Up @@ -55,7 +55,7 @@ <h1>
</li>
</ul>
</nav>
<div class="content">
<div class="odoc-content">
<h2 id="empty-section">
<a href="#empty-section" class="anchor"></a>Empty section
</h2>
Expand Down
8 changes: 4 additions & 4 deletions test/html/expect/test_package+custom_theme,ml/Val/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<nav>
<body class="odoc">
<nav class="odoc-nav">
<a href="../index.html">Up</a> – <a href="../index.html">test_package+custom_theme,ml</a> » Val
</nav>
<header>
<header class="odoc-preamble">
<h1>
Module <code>Val</code>
</h1>
</header>
<div class="content">
<div class="odoc-content">
<div>
<div class="spec value" id="val-documented">
<a href="#val-documented" class="anchor"></a><code><span class="keyword">val</span> documented : unit</code>
Expand Down
8 changes: 4 additions & 4 deletions test/html/expect/test_package+ml/Alias/X/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<nav>
<body class="odoc">
<nav class="odoc-nav">
<a href="../index.html">Up</a> – <a href="../../index.html">test_package+ml</a> » <a href="../index.html">Alias</a> » X
</nav>
<header>
<header class="odoc-preamble">
<h1>
Module <code>Alias.X</code>
</h1>
</header>
<div class="content">
<div class="odoc-content">
<div>
<div class="spec type" id="type-t">
<a href="#type-t" class="anchor"></a><code><span class="keyword">type</span> t = int</code>
Expand Down
8 changes: 4 additions & 4 deletions test/html/expect/test_package+ml/Alias/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<nav>
<body class="odoc">
<nav class="odoc-nav">
<a href="../index.html">Up</a> – <a href="../index.html">test_package+ml</a> » Alias
</nav>
<header>
<header class="odoc-preamble">
<h1>
Module <code>Alias</code>
</h1>
</header>
<div class="content">
<div class="odoc-content">
<div class="spec module" id="module-Foo__X">
<a href="#module-Foo__X" class="anchor"></a><code><span class="keyword">module</span> <a href="Foo__X/index.html">Foo__X</a> : <span class="keyword">sig</span> ... <span class="keyword">end</span></code>
</div>
Expand Down
8 changes: 4 additions & 4 deletions test/html/expect/test_package+ml/Bugs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<nav>
<body class="odoc">
<nav class="odoc-nav">
<a href="../index.html">Up</a> – <a href="../index.html">test_package+ml</a> » Bugs
</nav>
<header>
<header class="odoc-preamble">
<h1>
Module <code>Bugs</code>
</h1>
</header>
<div class="content">
<div class="odoc-content">
<div class="spec type" id="type-opt">
<a href="#type-opt" class="anchor"></a><code><span class="keyword">type</span> <span>'a opt</span> = <span><span class="type-var">'a</span> option</span></code>
</div>
Expand Down
8 changes: 4 additions & 4 deletions test/html/expect/test_package+ml/Bugs_post_406/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<nav>
<body class="odoc">
<nav class="odoc-nav">
<a href="../index.html">Up</a> – <a href="../index.html">test_package+ml</a> » Bugs_post_406
</nav>
<header>
<header class="odoc-preamble">
<h1>
Module <code>Bugs_post_406</code>
</h1>
<p>
Let-open in class types, https://github.com/ocaml/odoc/issues/543 This was added to the language in 4.06
</p>
</header>
<div class="content">
<div class="odoc-content">
<div class="spec class-type" id="class-type-let_open">
<a href="#class-type-let_open" class="anchor"></a><code><span class="keyword">class</span> <span class="keyword">type</span> <a href="class-type-let_open/index.html">let_open</a> = <span class="keyword">object</span> ... <span class="keyword">end</span></code>
</div>
Expand Down
8 changes: 4 additions & 4 deletions test/html/expect/test_package+ml/Bugs_pre_410/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<nav>
<body class="odoc">
<nav class="odoc-nav">
<a href="../index.html">Up</a> – <a href="../index.html">test_package+ml</a> » Bugs_pre_410
</nav>
<header>
<header class="odoc-preamble">
<h1>
Module <code>Bugs_pre_410</code>
</h1>
</header>
<div class="content">
<div class="odoc-content">
<div class="spec type" id="type-opt'">
<a href="#type-opt'" class="anchor"></a><code><span class="keyword">type</span> <span>'a opt'</span> = <span>int option</span></code>
</div>
Expand Down
8 changes: 4 additions & 4 deletions test/html/expect/test_package+ml/Class/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<nav>
<body class="odoc">
<nav class="odoc-nav">
<a href="../index.html">Up</a> – <a href="../index.html">test_package+ml</a> » Class
</nav>
<header>
<header class="odoc-preamble">
<h1>
Module <code>Class</code>
</h1>
</header>
<div class="content">
<div class="odoc-content">
<div class="spec class-type" id="class-type-empty">
<a href="#class-type-empty" class="anchor"></a><code><span class="keyword">class</span> <span class="keyword">type</span> <a href="class-type-empty/index.html">empty</a> = <span class="keyword">object</span> ... <span class="keyword">end</span></code>
</div>
Expand Down
8 changes: 4 additions & 4 deletions test/html/expect/test_package+ml/External/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<nav>
<body class="odoc">
<nav class="odoc-nav">
<a href="../index.html">Up</a> – <a href="../index.html">test_package+ml</a> » External
</nav>
<header>
<header class="odoc-preamble">
<h1>
Module <code>External</code>
</h1>
</header>
<div class="content">
<div class="odoc-content">
<div>
<div class="spec external" id="val-foo">
<a href="#val-foo" class="anchor"></a><code><span class="keyword">val</span> foo : unit <span>-&gt;</span> unit</code>
Expand Down
8 changes: 4 additions & 4 deletions test/html/expect/test_package+ml/Functor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<nav>
<body class="odoc">
<nav class="odoc-nav">
<a href="../index.html">Up</a> – <a href="../index.html">test_package+ml</a> » Functor
</nav>
<header>
<header class="odoc-preamble">
<h1>
Module <code>Functor</code>
</h1>
</header>
<div class="content">
<div class="odoc-content">
<div class="spec module-type" id="module-type-S">
<a href="#module-type-S" class="anchor"></a><code><span class="keyword">module</span> <span class="keyword">type</span> <a href="module-type-S/index.html">S</a> = <span class="keyword">sig</span> ... <span class="keyword">end</span></code>
</div>
Expand Down
Loading