Fossil SCM

fossil-scm / www / embeddeddoc.wiki
Source Blame History 268 lines
de6a590… drh 1 <title>Project Documentation</title>
4b826ee… drh 2
c8893c6… drh 3 Fossil provides a built-in <a href="wikitheory.wiki">wiki</a>
c8893c6… drh 4 that can be used to store the
4b826ee… drh 5 documentation for a project. This is sufficient for many projects.
4b826ee… drh 6 If your project is well-served by wiki documentation, then you
4b826ee… drh 7 need read no further.
4b826ee… drh 8
4b826ee… drh 9 But fossil also supports embedding project documentation as
4b826ee… drh 10 files in the source tree. There are several potential advantages
4b826ee… drh 11 to this approach:
4b826ee… drh 12
4b826ee… drh 13 1. The documentation files are versioned together with the
4b826ee… drh 14 source code files so it is always clear what version of
4b826ee… drh 15 the documentation goes with a particular release.
4b826ee… drh 16
4b826ee… drh 17 2. The documentation files can be edited using your favorite
4b826ee… drh 18 text editor instead of having to use the web-based wiki
4b826ee… drh 19 editor.
4b826ee… drh 20
4b826ee… drh 21 3. Only people with check-in privileges can modify the documentation.
4b826ee… drh 22 (This might be either an advantage or disadvantage, depending
4b826ee… drh 23 on the nature of your project.)
4b826ee… drh 24
8d8a41d… drh 25 We will call documentation that is included as files in the source tree
4b826ee… drh 26 "embedded documentation".
4b826ee… drh 27
45427ae… drh 28 <h1>1.0 Fossil Support For Embedded Documentation</h1>
4b826ee… drh 29
4b826ee… drh 30 The fossil web interface supports embedded documentation using
4b826ee… drh 31 the "/doc" page. To access embedded documentation, one points
4b826ee… drh 32 a web browser to a fossil URL of the following form:
4b826ee… drh 33
8a1ba49… wyoung 34 <pre>
4b826ee… drh 35 <i>&lt;baseurl&gt;</i><big><b>/doc/</b></big><i>&lt;version&gt;</i><big><b>/</b></big><i>&lt;filename&gt;</i>
8a1ba49… wyoung 36 </pre>
4b826ee… drh 37
4b826ee… drh 38 The <i>&lt;baseurl&gt;</i> is the main URL used to access the fossil web server.
4b826ee… drh 39 For example, the <i>&lt;baseurl&gt;</i> for the fossil project itself is
09908ab… drh 40 [https://fossil-scm.org/home].
c64f28d… drh 41 If you launch the web server using the "[/help/ui|fossil ui]" command line,
4b826ee… drh 42 then the <i>&lt;baseurl&gt;</i> is usually
4b826ee… drh 43 <b>http://localhost:8080/</b>.
4b826ee… drh 44
51511b7… wyoung 45 The <i>&lt;version&gt;</i> is the
51511b7… wyoung 46 [./checkin_names.wiki|name of a check-in]
c5d9ca6… drh 47 that contains the embedded document. This might be a hash prefix for
c5d9ca6… drh 48 the check-in, or it might be the name of a branch or tag, or it might
51511b7… wyoung 49 be a timestamp. See the prior link
51511b7… wyoung 50 for more possibilities and examples.
51511b7… wyoung 51
93cee1f… wyoung 52 The <i id="ckout">&lt;version&gt;</i> can
c5d9ca6… drh 53 also be the special identifier "<b>ckout</b>".
c5d9ca6… drh 54 The "<b>ckout</b>" keywords means to
4b826ee… drh 55 pull the documentation file from the local source tree on disk, not
c5d9ca6… drh 56 from the any check-in. The "<b>ckout</b>" keyword
fd1282e… drh 57 only works when you start your server using the
c64f28d… drh 58 "[/help/server|fossil server]" or "[/help?cmd=ui|fossil ui]"
c5d9ca6… drh 59 commands. The "/doc/ckout" URL is intended to show a preview of
b13c82f… wyoung 60 the documentation you are currently editing but have not yet checked in.
51511b7… wyoung 61
51511b7… wyoung 62 The original designed purpose of the "ckout" feature is to allow the
51511b7… wyoung 63 user to preview local changes to documentation before committing the
51511b7… wyoung 64 change. This is an important facility, since unlike other document
51511b7… wyoung 65 languages like HTML, there is still a lot of variation among rendering
51511b7… wyoung 66 engines for Fossil's markup languages, Markdown and Fossil Wiki. Your
51511b7… wyoung 67 changes may look fine in your whizzy GUI Markdown editor, but what
51511b7… wyoung 68 actually matters is how <i>Fossil</i> will interpret your Markdown text.
51511b7… wyoung 69 Therefore, you should always preview your edits before committing them.
433b9df… drh 70
433b9df… drh 71 To help make "ckout" easier to use, the "[/help?cmd=ui|fossil ui]"
433b9df… drh 72 command has the "--ckout-alias NAME" option that makes NAME an
433b9df… drh 73 alias for "ckout". If you are editing a collection of documents
433b9df… drh 74 that have hardcoded links to one another in the form of
433b9df… drh 75 "/doc/trunk/...", for example, you can test your changes by
433b9df… drh 76 running "fossil ui --ckout-alias trunk" and all of the links will
433b9df… drh 77 point to your uncommitted edits rather than to the latest trunk
433b9df… drh 78 check-in.
7c2577b… drh 79
7c2577b… drh 80 Finally, the <i>&lt;filename&gt;</i> element of the URL is the
7c2577b… drh 81 pathname of the documentation file relative to the root of the source
4b826ee… drh 82 tree.
4b826ee… drh 83
f47b705… jan.nijtmans 84 The mimetype (and thus the rendering) of documentation files is
f47b705… jan.nijtmans 85 determined by the file suffix. Fossil currently understands
de6a590… drh 86 [/mimetype_list|many different file suffixes],
de6a590… drh 87 including all the popular ones such as ".css", ".gif", ".htm",
de6a590… drh 88 ".html", ".jpg", ".jpeg", ".png", and ".txt".
5150b9d… drh 89
f47b705… jan.nijtmans 90 Documentation files whose names end in ".wiki" use the
5fcc1d5… drh 91 [/wiki_rules | fossil wiki markup] -
5150b9d… drh 92 a safe subset of HTML together with some wiki rules for paragraph
f47b705… jan.nijtmans 93 breaks, lists, and hyperlinks.
7794d72… drh 94 Documentation files ending in ".md" or ".markdown" use the
ca1a1a7… drh 95 [/md_rules | Markdown markup language].
7794d72… drh 96 Documentation files ending in ".txt" are plain text.
7794d72… drh 97 Wiki, markdown, and plain text documentation files
4b826ee… drh 98 are rendered with the standard fossil header and footer added.
de6a590… drh 99 Most other mimetypes are delivered directly to the requesting
8d8a41d… drh 100 web browser without interpretation, additions, or changes.
ca1a1a7… drh 101
93cee1f… wyoung 102 <h2 id="html">1.1 HTML Rendering With Fossil Headers And Footers</h2>
45427ae… drh 103
93cee1f… wyoung 104 Files with the mimetype "text/html" (the .html or .htm suffix) are
f47b705… jan.nijtmans 105 usually rendered directly to the browser without interpretation.
de6a590… drh 106 However, if the file begins with a &lt;div&gt; element like this:
de6a590… drh 107
de6a590… drh 108 <b>&lt;div class='fossil-doc' data-title='<i>Title Text</i>'&gt;</b>
de6a590… drh 109
de6a590… drh 110 Then the standard Fossil header and footer are added to the document
de6a590… drh 111 prior to being displayed. The "class='fossil-doc'" attribute is
de6a590… drh 112 required for this to occur. The "data-title='...'" attribute is
de6a590… drh 113 optional, but if it is present the text will become the title displayed
c5d9ca6… drh 114 in the Fossil header. An example of this can be seen in Fossil
c5d9ca6… drh 115 Documentation Index www/permutedindex.html:
c5d9ca6… drh 116
c5d9ca6… drh 117 * [/file/www/permutedindex.html?txt|source text for <b>www/permutedindex.html</b>]
c5d9ca6… drh 118 * [/doc/trunk/www/permutedindex.html|<b>www/permutedindex.html</b> rendered as HTML]
4e6d36d… wyoung 119
4e6d36d… wyoung 120 Beware that such HTML files render in the same browser security context
4e6d36d… wyoung 121 as all other embedded documentation served from Fossil; they are not
4e6d36d… wyoung 122 fully-independent web pages. One practical consequence of this is that
4e6d36d… wyoung 123 embedded <tt>&lt;script&gt;</tt> tags will cause a
4e6d36d… wyoung 124 [https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | Content
4e6d36d… wyoung 125 Security Policy] error in your browser with the default CSP as served by
f4cbfd5… wyoung 126 Fossil. See the documentation on [./customskin.md#headfoot | Header and
f4cbfd5… wyoung 127 Footer Processing] and [./defcsp.md | The Default CSP].
f4cbfd5… wyoung 128
f4cbfd5… wyoung 129
45427ae… drh 130 <h1>2.0 Server-Side Text Substitution</h1>
f146e21… drh 131
f146e21… drh 132 Fossil can do a few types of substitution of server-side information
f146e21… drh 133 into the embedded document.
f146e21… drh 134
45427ae… drh 135 <h2>2.1 "$ROOT" In HTML and Markdown Hyperlinks</h2>
45427ae… drh 136
fd1282e… drh 137 Hyperlinks in Markdown and HTML embedded documents can reference
45427ae… drh 138 the root of the Fossil repository using the special text "$ROOT"
45427ae… drh 139 at the beginning of a URL. For example, a Markdown hyperlink to
45427ae… drh 140 the Markdown formatting rules might be
45427ae… drh 141 written in the embedded document like this:
45427ae… drh 142
8a1ba49… wyoung 143 <verbatim>
8a1ba49… wyoung 144 [Markdown formatting rules]($ROOT/wiki_rules)
8a1ba49… wyoung 145 </verbatim>
45427ae… drh 146
45427ae… drh 147 Depending on how the how the Fossil server is configured, that hyperlink
45427ae… drh 148 might be renderer like one of the following:
45427ae… drh 149
8a1ba49… wyoung 150 <verbatim>
8a1ba49… wyoung 151 <a href="/wiki_rules">Wiki formatting rule</a>
8a1ba49… wyoung 152 <a href="/cgi-bin/fossil/wiki_rules">Wiki formatting rules</a>
8a1ba49… wyoung 153 </verbatim>
45427ae… drh 154
45427ae… drh 155 So, in other words, the "$ROOT" text is converted into whatever
45427ae… drh 156 the "&lt;baseurl&gt;" is for the document.
45427ae… drh 157
45427ae… drh 158 This substitution works for HTML and Markdown documents.
45427ae… drh 159 It does not work for Wiki embedded documents, since with
45427ae… drh 160 Wiki you can just begin a URL with "/" and it automatically knows
45427ae… drh 161 to prepend the $ROOT.
45427ae… drh 162
45427ae… drh 163 <h2>2.2 "$CURRENT" In "/doc/" Hyperlinks</h2>
45427ae… drh 164
45427ae… drh 165 Similarly, URLs of the form "/doc/$CURRENT/..." have the check-in
45427ae… drh 166 hash of the check-in currently being viewed substituted in place of
45427ae… drh 167 the "$CURRENT" text. This feature, in combination with the "$ROOT"
45427ae… drh 168 substitution above, allows an absolute path to be used for hyperlinks.
45427ae… drh 169
45427ae… drh 170 For example, if an embedded document documented wanted to reference
45427ae… drh 171 some other document in a separate file named "www/otherdoc.md",
45427ae… drh 172 it could use a URL like this:
45427ae… drh 173
8a1ba49… wyoung 174 <verbatim>
8a1ba49… wyoung 175 [Other Document]($ROOT/doc/$CURRENT/www/otherdoc.md)
8a1ba49… wyoung 176 </verbatim>
45427ae… drh 177
45427ae… drh 178 As with "$ROOT", this substitution only works for Markdown and HTML
45427ae… drh 179 documents. For Wiki documents, you would need to use a relative URL.
45427ae… drh 180
45427ae… drh 181 <h2 id="th1">2.3 TH1 Documents</h2>
45427ae… drh 182
17e79ab… stephan 183 Enabling TH1 document support requires the following:
17e79ab… stephan 184
17e79ab… stephan 185 * Configure the build with the <code>--with-th1-docs</code> flag.
17e79ab… stephan 186 * Enable the <code>th1-docs</code> setting, which is only available
17e79ab… stephan 187 after building with <code>--with-th1-docs</code>.
17e79ab… stephan 188 * Affected files must have a <code>.th1</code> file extension.
17e79ab… stephan 189 * The code to run must be embedded in blocks of
17e79ab… stephan 190 <code>&lt;th1>...&lt;/th1></code>.
17e79ab… stephan 191
17e79ab… stephan 192 Fossil will substitute the value of [./th1.md | TH1 expressions]
17e79ab… stephan 193 within the <code>&lt;th1>...&lt;/th1></code> blocks into
17e79ab… stephan 194 the output HTML.
45427ae… drh 195
45427ae… drh 196 Since TH1 is a full scripting language, this feature essential grants
17e79ab… stephan 197 the ability to execute code on the server to anyone with check-in
45427ae… drh 198 privilege for the project.
45427ae… drh 199 This is a security risk that needs to be carefully managed.
45427ae… drh 200 The feature is off by default.
45427ae… drh 201 Administrators should understand and carefully assess the risks
45427ae… drh 202 before enabling the use of TH1 within embedded documentation.
45427ae… drh 203
45427ae… drh 204
45427ae… drh 205 <h1>3.0 Examples</h1>
4b826ee… drh 206
4b826ee… drh 207 This file that you are currently reading is an example of
4b826ee… drh 208 embedded documentation. The name of this file in the fossil
4b826ee… drh 209 source tree is "<b>www/embeddeddoc.wiki</b>".
4b826ee… drh 210 You are perhaps looking at this
c8893c6… drh 211 file using the URL:
c8893c6… drh 212
8a1ba49… wyoung 213 <pre>[https://fossil-scm.org/home/doc/trunk/www/embeddeddoc.wiki]</pre>
4b826ee… drh 214
143f1db… wyoung 215 The first part of this path, the "[https://fossil-scm.org/home]",
4b826ee… drh 216 is the base URL. You might have originally typed:
143f1db… wyoung 217 [https://fossil-scm.org/]. The web server at the fossil-scm.org
0627f28… drh 218 site automatically redirects such links by appending "home". The
71499f1… drh 219 "home" file on fossil-scm.org is really a [./server/any/cgi.md|CGI script]
c5d9ca6… drh 220 which runs the fossil web service in CGI mode.
0627f28… drh 221 The "home" CGI script looks like this:
4b826ee… drh 222
8a1ba49… wyoung 223 <pre>
4b826ee… drh 224 #!/usr/bin/fossil
4b826ee… drh 225 repository: /fossil/fossil.fossil
8a1ba49… wyoung 226 </pre>
7794d72… drh 227
f146e21… drh 228 This is one of the many ways to set up a
f146e21… drh 229 <a href="./server/">Fossil server</a>.
7794d72… drh 230
7794d72… drh 231 The "<b>/trunk/</b>" part of the URL tells fossil to use
7794d72… drh 232 the documentation files from the most recent trunk check-in.
7794d72… drh 233 If you wanted to see an historical version of this document,
7794d72… drh 234 you could substitute the name of a check-in for "<b>/trunk/</b>".
7794d72… drh 235 For example, to see the version of this document associated with
7794d72… drh 236 check-in [9be1b00392], simply replace the "<b>/trunk/</b>" with
5c65487… drh 237 "<b>/9be1b00392/</b>". You can also substitute the symbolic name
5c65487… drh 238 for a particular version or branch. For example, you might
7794d72… drh 239 replace "<b>/trunk/</b>" with "<b>/experimental/</b>" to get the latest
7794d72… drh 240 version of this document in the "experimental" branch. The symbolic name
7c2577b… drh 241 can also be a date and time string in any of the following formats:</p>
7c2577b… drh 242
7c2577b… drh 243 <ul>
7c2577b… drh 244 <li> <i>YYYY-MM-DD</i>
99e6f71… wyoung 245 <li> <i>YYYY-MM-DD<b>T</b>HH:MM</i>
99e6f71… wyoung 246 <li> <i>YYYY-MM-DD<b>T</b>HH:MM:SS</i>
7c2577b… drh 247 </ul>
7c2577b… drh 248
f47b705… jan.nijtmans 249 When the symbolic name is a date and time, fossil shows the version
7c2577b… drh 250 of the document that was most recently checked in as of the date
7c2577b… drh 251 and time specified. So, for example, to see what the fossil website
7c2577b… drh 252 looked like at the beginning of 2010, enter:
7c2577b… drh 253
e012f50… juef 254 <pre><a href="https://fossil-scm.org/home/doc/2010-01-01/www/index.wiki">https://fossil-scm.org/home/doc/<b>2010-01-01</b>/www/index.wiki
8a1ba49… wyoung 255 </a></pre>
5c65487… drh 256
5c65487… drh 257 The file that encodes this document is stored in the fossil source tree under
5c65487… drh 258 the name "<b>www/embeddeddoc.wiki</b>" and so that name forms the
5c65487… drh 259 last part of the URL for this document.
4b826ee… drh 260
4b826ee… drh 261 As I sit writing this documentation file, I am testing my work by
7794d72… drh 262 running the "<b>fossil ui</b>" command line and viewing
4b826ee… drh 263 <b>http://localhost:8080/doc/ckout/www/embeddeddoc.wiki</b> in
4b826ee… drh 264 Firefox. I am doing this even though I have not yet checked in
4b826ee… drh 265 the "<b>www/embeddeddoc.wiki</b>" file for the first time. Using
4b826ee… drh 266 the special "<b>ckout</b>" version identifier on the "<b>/doc</b>" page
4b826ee… drh 267 it is easy to make multiple changes to multiple files and see how they all
4b826ee… drh 268 look together before committing anything to the repository.

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button