-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds explanations and improve occurrence tests
Signed-off-by: Paul-Elliot <peada@free.fr>
- Loading branch information
Showing
5 changed files
with
39 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,5 @@ | |
|
||
(cram | ||
(enabled_if | ||
(= %{ocaml_version} 4.14.0)) | ||
(= %{ocaml_version} 4.14.1)) | ||
(deps %{bin:odoc} %{bin:odoc_print})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1 @@ | ||
type t = string | ||
|
||
let x = 2 | ||
let y = x + 1 | ||
let z a = if x = 1 || true then x + y else 0 | ||
|
||
module A = struct end | ||
module B = A | ||
|
||
module type T = sig end | ||
module type U = T | ||
|
||
type ext = .. | ||
type ext += Foo | ||
|
||
exception Exn | ||
|
||
class cls = object end | ||
class cls' = cls | ||
class type ct = object end | ||
let a = B.b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let b = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,155 +1,37 @@ | ||
Files containing some values: | ||
When both source rendering and occurrence counting are enabled, the occurrences information are used to generate "jump to documentation" links. | ||
|
||
$ cat a.ml | ||
type t = string | ||
|
||
let x = 2 | ||
let y = x + 1 | ||
let z a = if x = 1 || true then x + y else 0 | ||
|
||
module A = struct end | ||
module B = A | ||
|
||
module type T = sig end | ||
module type U = T | ||
|
||
type ext = .. | ||
type ext += Foo | ||
|
||
exception Exn | ||
|
||
class cls = object end | ||
class cls' = cls | ||
class type ct = object end | ||
This test tests this. | ||
|
||
Source pages require a parent: | ||
Files containing some values: | ||
|
||
$ odoc compile -c module-a -c src-source root.mld | ||
$ cat a.ml | head -n 3 | ||
let a = B.b | ||
|
||
Compile the modules: | ||
$ cat b.ml | head -n 3 | ||
let b = 3 | ||
|
||
$ ocamlc -c a.ml -bin-annot | ||
Source pages require a parent: | ||
|
||
Compile the pages without --source: | ||
$ odoc compile -c module-a -c module-b -c src-source root.mld | ||
|
||
$ odoc compile a.cmt | ||
$ odoc link -I . a.odoc | ||
$ odoc html-generate --indent -o html a.odocl | ||
|
||
No source links are generated in the documentation: | ||
Compile the modules: | ||
|
||
$ ! grep source_link html/A/index.html -B 2 | ||
$ ocamlc -c b.ml -bin-annot | ||
$ ocamlc -c a.ml -I . -bin-annot | ||
|
||
Now, compile the pages with the --source option: | ||
Compile the pages with the source and occurrences options | ||
|
||
$ printf "a.ml\n" > source_tree.map | ||
$ printf "a.ml\nb.ml\n" > source_tree.map | ||
$ odoc source-tree -I . --parent page-root -o src-source.odoc source_tree.map | ||
|
||
$ odoc compile -I . --source-name a.ml --source-parent-file src-source.odoc a.cmt | ||
$ odoc compile --count-occurrences -I . --source-name b.ml --source-parent-file src-source.odoc b.cmt | ||
$ odoc compile --count-occurrences -I . --source-name a.ml --source-parent-file src-source.odoc a.cmt | ||
$ odoc link -I . b.odoc | ||
$ odoc link -I . a.odoc | ||
$ odoc html-generate --source b.ml --indent -o html b.odocl | ||
$ odoc html-generate --source a.ml --indent -o html a.odocl | ||
$ odoc support-files -o html | ||
|
||
Source links generated in the documentation: | ||
|
||
$ grep source_link html/A/index.html -B 2 | ||
<header class="odoc-preamble"> | ||
<h1>Module <code><span>A</span></code> | ||
<a href="../root/source/a.ml.html" class="source_link">Source</a> | ||
-- | ||
<div class="spec type anchored" id="type-t"> | ||
<a href="#type-t" class="anchor"></a> | ||
<a href="../root/source/a.ml.html#def-0" class="source_link">Source</a> | ||
-- | ||
<div class="spec value anchored" id="val-x"> | ||
<a href="#val-x" class="anchor"></a> | ||
<a href="../root/source/a.ml.html#def-1" class="source_link">Source</a> | ||
-- | ||
<div class="spec value anchored" id="val-y"> | ||
<a href="#val-y" class="anchor"></a> | ||
<a href="../root/source/a.ml.html#def-2" class="source_link">Source</a> | ||
-- | ||
<div class="spec value anchored" id="val-z"> | ||
<a href="#val-z" class="anchor"></a> | ||
<a href="../root/source/a.ml.html#def-3" class="source_link">Source</a> | ||
-- | ||
<div class="spec module anchored" id="module-A"> | ||
<a href="#module-A" class="anchor"></a> | ||
<a href="../root/source/a.ml.html#def-5" class="source_link">Source</a> | ||
-- | ||
<div class="spec module anchored" id="module-B"> | ||
<a href="#module-B" class="anchor"></a> | ||
<a href="../root/source/a.ml.html#def-5" class="source_link">Source</a> | ||
-- | ||
<div class="spec module-type anchored" id="module-type-T"> | ||
<a href="#module-type-T" class="anchor"></a> | ||
<a href="../root/source/a.ml.html#def-7" class="source_link">Source</a> | ||
-- | ||
<div class="spec module-type anchored" id="module-type-U"> | ||
<a href="#module-type-U" class="anchor"></a> | ||
<a href="../root/source/a.ml.html#def-8" class="source_link">Source</a> | ||
-- | ||
<div class="spec type anchored" id="type-ext"> | ||
<a href="#type-ext" class="anchor"></a> | ||
<a href="../root/source/a.ml.html#def-9" class="source_link">Source</a> | ||
-- | ||
<div class="spec type extension anchored" id="extension-decl-Foo"> | ||
<a href="#extension-decl-Foo" class="anchor"></a> | ||
<a href="../root/source/a.ml.html#def-10" class="source_link">Source</a> | ||
-- | ||
<div class="spec exception anchored" id="exception-Exn"> | ||
<a href="#exception-Exn" class="anchor"></a> | ||
<a href="../root/source/a.ml.html#def-11" class="source_link">Source</a> | ||
-- | ||
<div class="spec class anchored" id="class-cls"> | ||
<a href="#class-cls" class="anchor"></a> | ||
<a href="../root/source/a.ml.html#def-12" class="source_link">Source</a> | ||
-- | ||
<div class="spec class anchored" id="class-cls'"> | ||
<a href="#class-cls'" class="anchor"></a> | ||
<a href="../root/source/a.ml.html#def-14" class="source_link">Source</a> | ||
-- | ||
<div class="spec class-type anchored" id="class-type-ct"> | ||
<a href="#class-type-ct" class="anchor"></a> | ||
<a href="../root/source/a.ml.html#def-15" class="source_link">Source</a> | ||
|
||
Ids generated in the source code: | ||
The source for a contains a link to the documentation of `B.b`, as it is used in the implementation: | ||
|
||
$ cat html/root/source/a.ml.html | tr '> ' '\n\n' | grep '^id' | ||
id="L1" | ||
id="L2" | ||
id="L3" | ||
id="L4" | ||
id="L5" | ||
id="L6" | ||
id="L7" | ||
id="L8" | ||
id="L9" | ||
id="L10" | ||
id="L11" | ||
id="L12" | ||
id="L13" | ||
id="L14" | ||
id="L15" | ||
id="L16" | ||
id="L17" | ||
id="L18" | ||
id="L19" | ||
id="L20" | ||
id="def-0" | ||
id="x_268" | ||
id="def-1" | ||
id="y_269" | ||
id="def-2" | ||
id="z_270" | ||
id="def-3" | ||
id="a_272" | ||
id="def-5" | ||
id="def-6" | ||
id="def-7" | ||
id="def-8" | ||
id="def-9" | ||
id="def-10" | ||
id="def-11" | ||
id="def-12" | ||
id="def-14" | ||
id="def-15" | ||
$ cat html/root/source/a.ml.html | tr '> ' '\n\n' | grep 'href' | grep val-b | ||
href="../../B/index.html#val-b" |