inweb-bootstrap/docs/inweb/M-wtaw.html

787 lines
63 KiB
HTML
Raw Normal View History

2019-02-04 22:26:45 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
2020-04-08 22:41:00 +00:00
<title>Webs, Tangling and Weaving</title>
2020-04-23 22:23:44 +00:00
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width initial-scale=1">
2019-02-04 22:26:45 +00:00
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="en-gb">
2020-04-20 22:26:08 +00:00
<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
2020-04-30 22:36:38 +00:00
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
2020-04-25 10:33:39 +00:00
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
2020-04-20 22:26:08 +00:00
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
2020-04-21 16:55:17 +00:00
<link href="../docs-assets/ConsoleText-Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
2020-04-23 22:23:44 +00:00
2019-02-04 22:26:45 +00:00
</head>
2020-04-25 10:33:39 +00:00
<body class="commentary-font">
<nav role="navigation">
2020-04-13 16:06:45 +00:00
<h1><a href="../index.html">
2020-04-20 22:26:08 +00:00
<img src="../docs-assets/Octagram.png" width=72 height=72">
2020-04-13 16:06:45 +00:00
</a></h1>
<ul><li><a href="index.html"><span class="selectedlink">inweb</span></a></li>
</ul><h2>Foundation Module</h2><ul>
<li><a href="../foundation-module/index.html">foundation</a></li>
<li><a href="../foundation-test/index.html">foundation-test</a></li>
2020-04-13 16:06:45 +00:00
</ul><h2>Example Webs</h2><ul>
2020-04-12 16:24:23 +00:00
<li><a href="../goldbach/index.html">goldbach</a></li>
<li><a href="../twinprimes/twinprimes.html">twinprimes</a></li>
2020-04-15 22:45:08 +00:00
<li><a href="../eastertide/index.html">eastertide</a></li>
2020-04-14 17:36:42 +00:00
</ul><h2>Repository</h2><ul>
2020-04-20 22:34:44 +00:00
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=18> github</a></li>
2020-04-14 17:36:42 +00:00
</ul><h2>Related Projects</h2><ul>
<li><a href="../../../inform/docs/index.html">inform</a></li>
<li><a href="../../../intest/docs/index.html">intest</a></li>
2020-04-13 16:06:45 +00:00
</ul>
</nav>
<main role="main">
2020-04-23 22:23:44 +00:00
<!--Weave of 'Webs, Tangling and Weaving' generated by Inweb-->
2020-04-30 22:36:38 +00:00
<div class="breadcrumbs">
<ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="index.html">inweb</a></li><li><a href="index.html#M">Manual</a></li><li><b>Webs, Tangling and Weaving</b></li></ul></div>
<p class="purpose">How to use Inweb to weave or tangle a web already written.</p>
2019-02-04 22:26:45 +00:00
2021-08-11 11:01:50 +00:00
<ul class="toc"><li><a href="M-wtaw.html#SP1">&#167;1. All-in-one webs</a></li><li><a href="M-wtaw.html#SP4">&#167;4. Multi-section webs</a></li><li><a href="M-wtaw.html#SP7">&#167;7. Tangling</a></li><li><a href="M-wtaw.html#SP10">&#167;10. Weaving</a></li><li><a href="M-wtaw.html#SP13">&#167;13. Weave tags</a></li><li><a href="M-wtaw.html#SP14">&#167;14. Modules</a></li><li><a href="M-wtaw.html#SP17">&#167;17. The section catalogue</a></li><li><a href="M-wtaw.html#SP18">&#167;18. Makefile</a></li><li><a href="M-wtaw.html#SP19">&#167;19. Gitignore</a></li><li><a href="M-wtaw.html#SP20">&#167;20. Ctags</a></li><li><a href="M-wtaw.html#SP21">&#167;21. README files</a></li><li><a href="M-wtaw.html#SP24">&#167;24. Semantic version numbering and build metadata</a></li></ul><hr class="tocbar">
2019-02-04 22:26:45 +00:00
2020-08-16 17:39:53 +00:00
<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. All-in-one webs. </b>A program written for use with Inweb is called a "web". Inweb was primarily
2019-02-04 22:26:45 +00:00
designed for large, multisection webs, but it can also be used in a much
simpler way on smaller webs. In this documentation we'll call those
"all-in-one webs", meaning that there is just a single source code file for
the program.
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">Such a file should be a UTF-8 encoded plain text file with the file
2020-04-22 22:57:09 +00:00
extension <span class="extract"><span class="extract-syntax">.inweb</span></span>. The following is a "hello world" example, which can
be found in the Inweb distribution as <span class="extract"><span class="extract-syntax">inweb/Examples/hellow.inweb</span></span>:
2019-02-04 22:26:45 +00:00
</p>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> </span><span class="element-syntax">Title</span><span class="plain-syntax">:</span><span class="string-syntax"> hellow</span>
<span class="plain-syntax"> </span><span class="element-syntax">Author</span><span class="plain-syntax">:</span><span class="string-syntax"> Graham Nelson</span>
<span class="plain-syntax"> </span><span class="element-syntax">Purpose</span><span class="plain-syntax">:</span><span class="string-syntax"> A minimal example of a C program written for inweb.</span>
<span class="plain-syntax"> </span><span class="element-syntax">Language</span><span class="plain-syntax">:</span><span class="string-syntax"> C</span>
2019-02-04 22:26:45 +00:00
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> </span><span class="function-syntax">@ =</span>
<span class="plain-syntax"> #include &lt;stdio.h&gt;</span>
2019-02-04 22:26:45 +00:00
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> int main(int argc, char *argv[]) {</span>
<span class="plain-syntax"> printf("Hello world!\n");</span>
<span class="plain-syntax"> }</span>
</pre>
2020-08-16 17:39:53 +00:00
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>This of course is just a regular C "hello world" program written below
2020-04-22 22:57:09 +00:00
the <span class="extract"><span class="extract-syntax">@ =</span></span> marker, and some metadata written above it. The metadata above
2019-02-04 22:26:45 +00:00
is called the "contents section": for a larger web, it would expand out
to something more like a contents page, though here it's more like a
title page. The Title, Author and Purpose make no functional difference
to the program produced - they are purely descriptive - but the Language
setting is another matter, as we shall see.
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">The contents end, and the code begins, when the first "paragraph" begins.
2019-02-04 22:26:45 +00:00
Code in an Inweb web is divided into paragraphs. The core Inform compiler
2020-04-22 22:57:09 +00:00
currently has 8362 paragraphs, whereas <span class="extract"><span class="extract-syntax">hellow</span></span> has just one. (If you are
2019-02-04 22:26:45 +00:00
reading this documentation in a web page or a PDF, you will see that it's
divided up into little numbered sections: those are individual paragraphs
2020-04-22 22:57:09 +00:00
from the <span class="extract"><span class="extract-syntax">inweb</span></span> web.) More on this below, but the use of an <span class="extract"><span class="extract-syntax">@</span></span> character
2019-02-04 22:26:45 +00:00
in column 1 of the web file is what marks a paragraph break.
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">As mentioned earlier, there are two basic things we can do with a web:
2019-02-04 22:26:45 +00:00
tangle, to make a program ready to compile and run; and weave, to make
a comfortably legible version for human eyes instead. Let's now tangle:
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb/Tangled/inweb</span><span class="ConsoleText-plain-syntax"> inweb/Examples/hellow.inweb</span><span class="ConsoleText-identifier-syntax"> -tangle</span>
<span class="ConsoleText-plain-syntax"> web "hellow": 1 section(s) : 1 paragraph(s) : 9 line(s)</span>
<span class="ConsoleText-plain-syntax"> tangling &lt;inweb/Examples/hellow.c&gt; (written in C)</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">And <span class="extract"><span class="ConsoleText-extract-syntax">inweb/Examples/hellow.c</span></span> is now a regular C program which can then be
2019-02-04 22:26:45 +00:00
compiled. If we had wanted it to be written somewhere else, or called
2020-04-22 22:57:09 +00:00
something else, we could have used <span class="extract"><span class="ConsoleText-extract-syntax">-tangle-to F</span></span> to specify a file <span class="extract"><span class="ConsoleText-extract-syntax">F</span></span>
2019-02-04 22:26:45 +00:00
to create instead.
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">In general, you never need to look at or edit tangled code, but if
2019-02-04 22:26:45 +00:00
we take a look at this one to see what has happened, two things are worth
noting.
</p>
2020-04-24 23:06:02 +00:00
<ul class="items"><li>(a) First, the use of the <span class="extract"><span class="ConsoleText-extract-syntax">#line</span></span> C preprocessor feature, which ensures that
2019-02-04 22:26:45 +00:00
any compilation errors occurring will be reported at the correct point of
origin in the original Inweb file, not in the tangled file.
2020-04-24 23:06:02 +00:00
</li><li>(b) Secondly, notice that the <span class="extract"><span class="ConsoleText-extract-syntax">main</span></span> function has automatically been
2019-02-04 22:26:45 +00:00
predeclared at the top of the file. Because Inweb does this for C programs,
the programmer can freely call functions defined lower down in the source
code, without having to write tiresome predeclarations or header files. (As it
2020-04-22 22:57:09 +00:00
happens, there was no need in the case of <span class="extract"><span class="ConsoleText-extract-syntax">main</span></span>, but nor was there any harm.)
2020-04-24 23:06:02 +00:00
</li></ul>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-24 23:06:02 +00:00
<span class="plain-syntax"> </span><span class="comment-syntax"> Tangled output generated by inweb: do not edit</span>
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> #</span><span class="identifier-syntax">include</span><span class="plain-syntax"> &lt;</span><span class="identifier-syntax">stdio</span><span class="plain-syntax">.</span><span class="identifier-syntax">h</span><span class="plain-syntax">&gt;</span>
<span class="plain-syntax"> #</span><span class="identifier-syntax">line</span><span class="plain-syntax"> </span><span class="constant-syntax">9</span><span class="plain-syntax"> </span><span class="string-syntax">"inweb/Examples/hellow.inweb"</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">main</span><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">argc</span><span class="plain-syntax">, </span><span class="reserved-syntax">char</span><span class="plain-syntax"> *</span><span class="identifier-syntax">argv</span><span class="plain-syntax">[]) ;</span>
<span class="plain-syntax"> #</span><span class="identifier-syntax">line</span><span class="plain-syntax"> </span><span class="constant-syntax">8</span><span class="plain-syntax"> </span><span class="string-syntax">"inweb/Examples/hellow.inweb"</span>
2019-02-04 22:26:45 +00:00
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">main</span><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">argc</span><span class="plain-syntax">, </span><span class="reserved-syntax">char</span><span class="plain-syntax"> *</span><span class="identifier-syntax">argv</span><span class="plain-syntax">[]) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">printf</span><span class="plain-syntax">(</span><span class="string-syntax">"Hello world!\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
</pre>
2020-08-16 17:39:53 +00:00
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>So much for tangling: we can also weave. <span class="extract"><span class="extract-syntax">hellow</span></span> is so uninteresting
2020-04-22 22:57:09 +00:00
to look at that this seems a good point to switch to <span class="extract"><span class="extract-syntax">inweb/Examples/twinprimes.inweb</span></span>,
2019-02-04 22:26:45 +00:00
a C program to find twin prime numbers. If we weave:
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb/Tangled/inweb</span><span class="ConsoleText-plain-syntax"> inweb/Examples/twinprimes.inweb</span><span class="ConsoleText-identifier-syntax"> -weave</span>
<span class="ConsoleText-plain-syntax"> web "twinprimes": 1 section(s) : 4 paragraph(s) : 48 line(s)</span>
<span class="ConsoleText-plain-syntax"> [Complete Program: HTML -&gt; inweb/Examples/twinprimes.html]</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">As with tangling, we can override this destination with <span class="extract"><span class="ConsoleText-extract-syntax">-weave-to F</span></span>, telling
2019-02-04 22:26:45 +00:00
Inweb to weave into just a single file (which in this instance it was going
2020-04-22 22:57:09 +00:00
to do anyway) and call it <span class="extract"><span class="ConsoleText-extract-syntax">F</span></span>; or we can similarly <span class="extract"><span class="ConsoleText-extract-syntax">-weave-into D</span></span>, telling
Inweb to weave a set of file into the directory <span class="extract"><span class="ConsoleText-extract-syntax">D</span></span>, rather than the usual
<span class="extract"><span class="ConsoleText-extract-syntax">Woven</span></span> subdirectory of the web in question.
2019-02-04 22:26:45 +00:00
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">By default, <span class="extract"><span class="ConsoleText-extract-syntax">-weave</span></span> makes an HTML representation of the program. (On a larger
2019-02-04 22:26:45 +00:00
web, with multiple sections, it would make a set of linked pages, but here
there's just one.) This can then be looked at with a browser such as Chrome or
Safari. HTML is not the only format we can produce. Inweb performs the weave
2020-04-22 22:57:09 +00:00
by following a "pattern", and it has several patterns built in, notably <span class="extract"><span class="ConsoleText-extract-syntax">HTML</span></span>,
<span class="extract"><span class="ConsoleText-extract-syntax">Ebook</span></span> and <span class="extract"><span class="ConsoleText-extract-syntax">TeX</span></span>.
2019-02-04 22:26:45 +00:00
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">Running Inweb with <span class="extract"><span class="ConsoleText-extract-syntax">-weave-as P</span></span> tells it to weave with pattern <span class="extract"><span class="ConsoleText-extract-syntax">P</span></span>; the
2020-04-22 22:57:09 +00:00
plain command <span class="extract"><span class="ConsoleText-extract-syntax">-weave</span></span> is equivalent to <span class="extract"><span class="ConsoleText-extract-syntax">-weave-as HTML</span></span>. The <span class="extract"><span class="ConsoleText-extract-syntax">Ebook</span></span> pattern
2019-02-04 22:26:45 +00:00
makes an EPUB file suitable for readers such as Apple's Books app, but that
would be overkill for such a tiny program. Instead:
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb/Tangled/inweb</span><span class="ConsoleText-plain-syntax"> inweb/Examples/twinprimes.inweb</span><span class="ConsoleText-identifier-syntax"> -weave-as</span><span class="ConsoleText-plain-syntax"> TeX</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">This will only work if you have the mathematical typesetting system TeX
2020-04-22 22:57:09 +00:00
installed, and in particular, the <span class="extract"><span class="ConsoleText-extract-syntax">pdftex</span></span> tool. (This comes as part of
2019-02-04 22:26:45 +00:00
the standard TeXLive distribution, so simply "installing TeX" on your
2020-04-22 22:57:09 +00:00
platform will probably install <span class="extract"><span class="ConsoleText-extract-syntax">pdftex</span></span> automatically.) Now the response
2019-02-04 22:26:45 +00:00
is like so:
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb/Tangled/inweb</span><span class="ConsoleText-plain-syntax"> inweb/Examples/twinprimes.inweb</span><span class="ConsoleText-identifier-syntax"> -weave-as</span><span class="ConsoleText-plain-syntax"> TeX</span>
<span class="ConsoleText-plain-syntax"> web "twinprimes": 1 section(s) : 4 paragraph(s) : 48 line(s)</span>
<span class="ConsoleText-plain-syntax"> [Complete Program: PDF -&gt; inweb/Examples/twinprimes.tex: 1pp 103K]</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">Inweb automatically creates <span class="extract"><span class="ConsoleText-extract-syntax">twinprimes.tex</span></span> and runs it through <span class="extract"><span class="ConsoleText-extract-syntax">pdftex</span></span>
2020-04-22 22:57:09 +00:00
to produce <span class="extract"><span class="ConsoleText-extract-syntax">twinprimes.pdf</span></span>: it reads over the TeX log file to see how
many pages that comes to, and reports back. All being well, the <span class="extract"><span class="ConsoleText-extract-syntax">.tex</span></span>
and <span class="extract"><span class="ConsoleText-extract-syntax">.log</span></span> files are silently removed, leaving just <span class="extract"><span class="ConsoleText-extract-syntax">twinprimes.pdf</span></span> behind.
2019-02-04 22:26:45 +00:00
</p>
2020-08-16 17:39:53 +00:00
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. Multi-section webs. </b>The <span class="extract"><span class="ConsoleText-extract-syntax">twinprimes.inweb</span></span> example was a program so small that it could
2019-02-04 22:26:45 +00:00
comfortably fit into one source file, but for really large programs, that
would be madness. The core Inform compiler, for example, runs to about
210,000 lines of code, and distributes those across 418 source files
called "sections", together with a special 419th section which forms
its contents page. It's a matter of personal taste how much should be
in a section, but an ideal section file might contain 500 to 1000 lines
of material and weave to a standalone essay, describing and implementing
a single well-defined component of the whole program.
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">In this documentation, we'll call such webs "multi-section".
2019-02-04 22:26:45 +00:00
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">A multi-section web is stored as a directory, whose name should be (a
2019-02-04 22:26:45 +00:00
short version of) the name of the program. For example, Inweb's own
2020-04-22 22:57:09 +00:00
source is in a directory called <span class="extract"><span class="ConsoleText-extract-syntax">inweb</span></span>. A web directory is a tidy,
2019-02-04 22:26:45 +00:00
self-contained area in which the program can be written, compiled and
used.
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">Inweb expects that a multi-section web will contain at least two source
2019-02-04 22:26:45 +00:00
files, each of which is a UTF-8 encoded text file with the file extension
2020-04-22 22:57:09 +00:00
<span class="extract"><span class="ConsoleText-extract-syntax">.w</span></span>. One source file is special, must always be called <span class="extract"><span class="ConsoleText-extract-syntax">Contents.w</span></span>,
2019-02-04 22:26:45 +00:00
and must be directly stored in the web directory. All other section files
are stored in subdirectories of the web directory:
</p>
2020-04-24 23:06:02 +00:00
<ul class="items"><li>(a) If the web is still relatively small, there may only be a few of these,
2020-04-22 22:57:09 +00:00
stored in a single subdirectory called <span class="extract"><span class="ConsoleText-extract-syntax">Sections</span></span>.
2020-04-24 23:06:02 +00:00
</li><li>(b) Alternatively (not additionally), a larger web can use chapter
2020-04-22 22:57:09 +00:00
subdirectories called <span class="extract"><span class="ConsoleText-extract-syntax">Manual</span></span>, <span class="extract"><span class="ConsoleText-extract-syntax">Preliminaries</span></span>, <span class="extract"><span class="ConsoleText-extract-syntax">Chapter 1</span></span>, <span class="extract"><span class="ConsoleText-extract-syntax">Chapter 2</span></span>, ...,
<span class="extract"><span class="ConsoleText-extract-syntax">Appendix A</span></span>, <span class="extract"><span class="ConsoleText-extract-syntax">Appendix B</span></span>, ...; preliminaries and appendices being optional.
2020-03-22 11:24:10 +00:00
(There can't be a Chapter 0, though there can be Appendix A, B, C, ..., L.)
2020-04-24 23:06:02 +00:00
</li></ul>
<p class="commentary">A multi-section web can contain a variety of other subdirectories as needed.
2020-04-22 22:57:09 +00:00
Two in particular, <span class="extract"><span class="ConsoleText-extract-syntax">Woven</span></span> and <span class="extract"><span class="ConsoleText-extract-syntax">Tangled</span></span>, are automatically created by Inweb
2019-02-04 22:26:45 +00:00
as needed to store the results of tangling and weaving, respectively: they
are not intended to hold any material of lasting value, and can be emptied
at any time and regenerated later.
</p>
2020-08-16 17:39:53 +00:00
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b>Uniquely, the <span class="extract"><span class="ConsoleText-extract-syntax">Contents.w</span></span> section provides neither typeset output nor
2019-02-04 22:26:45 +00:00
compiled code: it is instead a roster telling Inweb about the rest of the
web, and how the other sections are organised. It has a completely different
syntax from all other sections. (It's essentially a fuller version of the
top part of an all-in-one web file as demonstrated above, but now it
occupies the whole file.)
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">The contents section opens with some bibliographic data. For example:
2019-02-04 22:26:45 +00:00
</p>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> </span><span class="element-syntax">Title</span><span class="plain-syntax">:</span><span class="string-syntax"> inter</span>
<span class="plain-syntax"> </span><span class="element-syntax">Author</span><span class="plain-syntax">:</span><span class="string-syntax"> Graham Nelson</span>
<span class="plain-syntax"> </span><span class="element-syntax">Purpose</span><span class="plain-syntax">:</span><span class="string-syntax"> For handling intermediate Inform code</span>
<span class="plain-syntax"> </span><span class="element-syntax">Language</span><span class="plain-syntax">:</span><span class="string-syntax"> InC</span>
<span class="plain-syntax"> </span><span class="element-syntax">Licence</span><span class="plain-syntax">:</span><span class="string-syntax"> Artistic License 2.0</span>
<span class="plain-syntax"> </span><span class="element-syntax">Version Number</span><span class="plain-syntax">:</span><span class="string-syntax"> 1</span>
<span class="plain-syntax"> </span><span class="element-syntax">Version Name</span><span class="plain-syntax">:</span><span class="string-syntax"> Axion</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">This is a simply a block of name-value pairs specifying some bibliographic
2019-02-04 22:26:45 +00:00
details; there is then a skipped line, and the roster of sections begins.
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">Note that the program's <span class="extract"><span class="extract-syntax">Title</span></span> need not be the same as the directory-name
2019-02-04 22:26:45 +00:00
for the web, which is useful if the program has a long or file-system-unfriendly
2020-04-22 22:57:09 +00:00
name. The <span class="extract"><span class="extract-syntax">Purpose</span></span> should be brief enough to fit onto one line. <span class="extract"><span class="extract-syntax">Licence</span></span> can
also have the US spelling, <span class="extract"><span class="extract-syntax">License</span></span>; Inweb treats these as equivalent.
2019-02-04 22:26:45 +00:00
Version number and name are, of course, optional.
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">The <span class="extract"><span class="extract-syntax">Language</span></span> is the programming language in which the code is written: much
2020-04-22 22:57:09 +00:00
more on that later on, but for now, the important ones are probably <span class="extract"><span class="extract-syntax">C</span></span>, <span class="extract"><span class="extract-syntax">InC</span></span>
and <span class="extract"><span class="extract-syntax">Plain Text</span></span>.
2019-02-04 22:26:45 +00:00
</p>
2020-08-16 17:39:53 +00:00
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. </b>After the header block of details, then, we have the roster of sections.
2019-02-04 22:26:45 +00:00
This is like a contents page &mdash; the order is the order in which the sections
are presented on any website, or in any of the larger PDFs woven. For a short,
unchaptered web, we might have for instance:
</p>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> Sections</span>
<span class="plain-syntax"> Program Control</span>
<span class="plain-syntax"> Command Line and Configuration</span>
<span class="plain-syntax"> Scan Documentation</span>
<span class="plain-syntax"> HTML and Javascript</span>
<span class="plain-syntax"> Renderer</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">And then Inweb will expect to find, for instance, the section file
2020-04-22 22:57:09 +00:00
<span class="extract"><span class="extract-syntax">Scan Documentation.w</span></span> in the <span class="extract"><span class="extract-syntax">Sections</span></span> directory.
2019-02-04 22:26:45 +00:00
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">A larger web, however, won't have a "Sections" directory. It may have a
2019-02-04 22:26:45 +00:00
much longer roster, such as:
</p>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> Preliminaries</span>
<span class="plain-syntax"> Preface</span>
<span class="plain-syntax"> Thematic Index</span>
<span class="plain-syntax"> Licence and Copyright Declaration</span>
<span class="plain-syntax"> BNF Grammar</span>
2020-04-07 22:04:32 +00:00
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> Chapter 1: Definitions</span>
<span class="plain-syntax"> "In which some globally-used constants are defined and the standard C libraries</span>
<span class="plain-syntax"> are interfaced with, with all the differences between platforms (Mac OS X,</span>
<span class="plain-syntax"> Windows, Linux, Solaris, Sugar/XO and so forth) taken care of once and for all."</span>
<span class="plain-syntax"> Basic Definitions</span>
<span class="plain-syntax"> Platform-Specific Definitions</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">... and so on...
2019-02-04 22:26:45 +00:00
</p>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> Appendix A: The Standard Rules (Independent Inform 7)</span>
<span class="plain-syntax"> "This is the body of Inform 7 source text automatically included with every</span>
<span class="plain-syntax"> project run through the Inform compiler, and which defines most of what end users</span>
<span class="plain-syntax"> see as the Inform language."</span>
<span class="plain-syntax"> SR0 - Preamble</span>
<span class="plain-syntax"> SR1 - Physical World Model</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">... and so on. Here the sections appear in directories called Preliminaries,
2020-03-22 11:24:10 +00:00
Chapter 1, Chapter 2, ..., Appendix A. (There can't be a Chapter 0, though
there can be Appendix B, C, ..., O; there can also be a Manual chapter, in
the sense of documentation.)
2019-02-04 22:26:45 +00:00
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">In case of any doubt we can use the following command-line switch to see
2020-04-22 22:57:09 +00:00
how Inweb is actually reading the sections of a web <span class="extract"><span class="extract-syntax">W</span></span>:
2019-02-04 22:26:45 +00:00
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb/Tangled/inweb</span><span class="ConsoleText-plain-syntax"> W</span><span class="ConsoleText-identifier-syntax"> -catalogue -verbose</span>
</pre>
2020-08-16 17:39:53 +00:00
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. Tangling. </b>At this point, it may be worth experimenting with a second mathematical
2020-04-22 22:57:09 +00:00
example: <span class="extract"><span class="ConsoleText-extract-syntax">inweb/Examples/goldbach</span></span>, which is to do with a problem in number
2019-02-04 22:26:45 +00:00
theory called the Goldbach Conjecture. This is a multi-section web, though
really only for the sake of an example: it's still a very small web.
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">This is once again a C program. Actually building and running this is a
2019-02-04 22:26:45 +00:00
little trouble, of course, and because there are multiple source files, it's
not so easy to keep track of whether the program is built up to date.
So a convenience of Inweb is that it can make makefiles to help with this:
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb/Tangled/inweb</span><span class="ConsoleText-plain-syntax"> inweb/Examples/goldbach</span><span class="ConsoleText-identifier-syntax"> -makefile</span><span class="ConsoleText-plain-syntax"> inweb/Examples/goldbach/goldbach.mk</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">With this done,
2019-02-04 22:26:45 +00:00
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">make</span><span class="ConsoleText-identifier-syntax"> -f</span><span class="ConsoleText-plain-syntax"> inweb/Examples/goldbach/goldbach.mk</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">tangles and then compiles the program as necessary. The tangling part of that
2019-02-04 22:26:45 +00:00
is nothing fancy - as before, it's just
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb/Tangled/inweb</span><span class="ConsoleText-plain-syntax"> inweb/Examples/goldbach</span><span class="ConsoleText-identifier-syntax"> -tangle</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">Assuming all goes well:
2019-02-04 22:26:45 +00:00
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb/Examples/goldbach/Tangled/goldbach</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">should then print out some results.
2019-02-04 22:26:45 +00:00
</p>
2020-08-16 17:39:53 +00:00
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. </b>It is legal in some circumstances to tangle only part of a web. This is done
2019-02-04 22:26:45 +00:00
by specifying a "range", much as will be seen later with weaving - but
because it's not normally meaningful to tangle only part of a program, the
possible ranges are much more restricted. In fact, the only partial tangles
2020-04-22 22:57:09 +00:00
allowed are for chapters or sections marked in the <span class="extract"><span class="ConsoleText-extract-syntax">Contents.w</span></span> as being
2019-02-04 22:26:45 +00:00
"Independent". For example:
</p>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> Appendix A: The Standard Rules (Independent Inform 7)</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">declares that Appendix A is a sort of sidekick program, written in the
2020-04-22 22:57:09 +00:00
language "Inform 7". As a result, it won't be included in a regular <span class="extract"><span class="extract-syntax">-tangle</span></span>,
2019-02-04 22:26:45 +00:00
and to obtain it we have to:
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb/Tangled/inweb</span><span class="ConsoleText-plain-syntax"> inform7</span><span class="ConsoleText-identifier-syntax"> -tangle</span><span class="ConsoleText-plain-syntax"> A</span>
</pre>
2020-08-16 17:39:53 +00:00
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. </b>In some C programs, it's useful to require that a header file be added to
2019-02-04 22:26:45 +00:00
a tangle. This can be done by adding:
</p>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> Header: H</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">to the contents page of a web. The heacer file <span class="extract"><span class="extract-syntax">H</span></span> in question should then
2020-04-22 22:57:09 +00:00
be stored in the web's <span class="extract"><span class="extract-syntax">Headers</span></span> subdirectory. (At one time, the Foundation
2019-02-04 22:26:45 +00:00
module used this to bring in a Windows-only header file.)
</p>
2020-08-16 17:39:53 +00:00
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. Weaving. </b>As with all-in-one webs, the commands for weaving are like so:
2019-02-04 22:26:45 +00:00
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb</span><span class="ConsoleText-plain-syntax"> inweb/Examples/goldbach</span><span class="ConsoleText-identifier-syntax"> -weave</span>
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb</span><span class="ConsoleText-plain-syntax"> inweb/Examples/goldbach</span><span class="ConsoleText-identifier-syntax"> -weave-as</span><span class="ConsoleText-plain-syntax"> TeX</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">This will produce single HTML or PDF files of the woven form of the whole
2019-02-04 22:26:45 +00:00
program. (Note that the PDF file now has a cover page: on a web with just
a single section, this wouldn't happen.) But with a growing web, that can
be cumbersome.
</p>
2020-08-16 17:39:53 +00:00
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. </b>After setting <span class="extract"><span class="ConsoleText-extract-syntax">-weave</span></span> or <span class="extract"><span class="ConsoleText-extract-syntax">-weave-as</span></span>, we can also optionally choose a
2020-04-22 22:57:09 +00:00
range. The default range is <span class="extract"><span class="ConsoleText-extract-syntax">all</span></span>, so up to now we have implicitly
2019-02-04 22:26:45 +00:00
been running weaves like these:
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb</span><span class="ConsoleText-plain-syntax"> inweb/Examples/goldbach</span><span class="ConsoleText-identifier-syntax"> -weave</span><span class="ConsoleText-plain-syntax"> all</span>
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb</span><span class="ConsoleText-plain-syntax"> inweb/Examples/goldbach</span><span class="ConsoleText-identifier-syntax"> -weave-as</span><span class="ConsoleText-plain-syntax"> TeX all</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">The opposite extreme from <span class="extract"><span class="ConsoleText-extract-syntax">all</span></span> is <span class="extract"><span class="ConsoleText-extract-syntax">sections</span></span>. This still weaves the entire
2019-02-04 22:26:45 +00:00
web, but now cuts it up into individual files, one for each section. For
example,
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb</span><span class="ConsoleText-plain-syntax"> inweb/Examples/goldbach</span><span class="ConsoleText-identifier-syntax"> -weave</span><span class="ConsoleText-plain-syntax"> sections</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">makes a miniature website; files include some CSS, and:
2019-02-04 22:26:45 +00:00
</p>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> inweb/Examples/goldbach/Woven/index.html</span>
<span class="plain-syntax"> inweb/Examples/goldbach/Woven/S-tgc.html</span>
<span class="plain-syntax"> inweb/Examples/goldbach/Woven/S-tsoe.html</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">Those abbreviated names <span class="extract"><span class="extract-syntax">S-tgc</span></span> and <span class="extract"><span class="extract-syntax">S-tsoe</span></span> are cut down from the full
2019-02-04 22:26:45 +00:00
names of the sections involved, "The Goldbach Conjecture" and "The Sieve
of Eratosthenes". Similarly,
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb</span><span class="ConsoleText-plain-syntax"> inweb/Examples/goldbach</span><span class="ConsoleText-identifier-syntax"> -weave-as</span><span class="ConsoleText-plain-syntax"> TeX sections</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">creates the files:
2019-02-04 22:26:45 +00:00
</p>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> inweb/Examples/goldbach/Woven/index.html</span>
<span class="plain-syntax"> inweb/Examples/goldbach/Woven/S-tgc.pdf</span>
<span class="plain-syntax"> inweb/Examples/goldbach/Woven/S-tsoe.pdf</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">The index file here is a table of contents offering links to the PDFs.
2019-02-04 22:26:45 +00:00
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">An intermediate level of granularity is the range <span class="extract"><span class="extract-syntax">chapters</span></span>, which makes
2019-02-04 22:26:45 +00:00
sense only for chaptered webs, and puts each chapter into its own file.
</p>
2020-08-16 17:39:53 +00:00
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. </b>Ranges can also be used to weave only part of a web:
2019-02-04 22:26:45 +00:00
</p>
2020-04-24 23:06:02 +00:00
<ul class="items"><li>(a) In a chaptered web, chapters are abbreviated to just their numbers: for
2020-04-22 22:57:09 +00:00
example, the range <span class="extract"><span class="extract-syntax">2</span></span> means "just Chapter 2". The Preliminaries alone is <span class="extract"><span class="extract-syntax">P</span></span>;
the Manual, <span class="extract"><span class="extract-syntax">M</span></span>. Appendix A, B, C are <span class="extract"><span class="extract-syntax">A</span></span>, <span class="extract"><span class="extract-syntax">B</span></span>, <span class="extract"><span class="extract-syntax">C</span></span> and so on. (This is why
2020-03-22 11:24:10 +00:00
Appendices can only run up to L.)
2020-04-24 23:06:02 +00:00
</li><li>(b) In an unchaptered web, <span class="extract"><span class="extract-syntax">S</span></span> means "all the sections". This is almost but not
2020-04-22 22:57:09 +00:00
quite the same as <span class="extract"><span class="extract-syntax">all</span></span>: the cover sheet (a sort of title page) is omitted.
2020-04-24 23:06:02 +00:00
</li><li>(c) The abbreviation for a section makes a range of just that section. For
2020-04-22 22:57:09 +00:00
example, <span class="extract"><span class="extract-syntax">S/tgc</span></span> and <span class="extract"><span class="extract-syntax">S/tsoe</span></span> in the Goldbach web example, or <span class="extract"><span class="extract-syntax">2/ec</span></span> for
2019-02-04 22:26:45 +00:00
the "Enumerated Constants" section of Chapter 2 of Inweb itself. Note that
2020-04-22 22:57:09 +00:00
running Inweb with <span class="extract"><span class="extract-syntax">-catalogue</span></span> shows all the sections of a web, and their
2020-04-03 15:29:03 +00:00
abbreviations. If it's a nuisance that these section ranges are hard to
2020-04-22 22:57:09 +00:00
predict, run with <span class="extract"><span class="extract-syntax">-sequential</span></span> to have them simply be <span class="extract"><span class="extract-syntax">X/s1</span></span>, <span class="extract"><span class="extract-syntax">X/s2</span></span>, ...,
within each chapter, where <span class="extract"><span class="extract-syntax">X</span></span> is the chapter range.
2020-04-24 23:06:02 +00:00
</li></ul>
2020-08-16 17:39:53 +00:00
<p class="commentary firstcommentary"><a id="SP13" class="paragraph-anchor"></a><b>&#167;13. Weave tags. </b>An alternative to a range is to specify a tag. Rather than weaving contiguous
2019-02-04 22:26:45 +00:00
pieces of the web, this collates together all those paragraphs with a given
tag. The result is a booklet of extracts.
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">Most paragraphs are never tagged. A tag is simply a word; paragraphs can have
2019-02-04 22:26:45 +00:00
multiple tags, but for each individual tags they either have it or don't.
A very few tags are automatically applied by Inweb:
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">If the program is for a C-like language, Inweb automatically tags any
2020-04-22 22:57:09 +00:00
paragraph containing a <span class="extract"><span class="extract-syntax">typedef struct</span></span> with the tag <span class="extract"><span class="extract-syntax">Structures</span></span>. So,
2019-02-04 22:26:45 +00:00
for example,
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb/Tangled/inweb</span><span class="ConsoleText-plain-syntax"> inweb</span><span class="ConsoleText-identifier-syntax"> -weave-tag</span><span class="ConsoleText-plain-syntax"> Structures</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">weaves just the structure definitions culled from a much larger web; this
2019-02-04 22:26:45 +00:00
can make a convenient reference. Similarly, any paragraph containing an
2020-04-22 22:57:09 +00:00
illustration is automatically tagged <span class="extract"><span class="ConsoleText-extract-syntax">Figures</span></span>, and any paragraph in an
<span class="extract"><span class="ConsoleText-extract-syntax">InC</span></span> web which defines Preform grammar is automatically tagged <span class="extract"><span class="ConsoleText-extract-syntax">Preform</span></span>.
2019-02-04 22:26:45 +00:00
(In the Inform project, this is used to generate the PDF of the formal
syntax of the language.)
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">All other tags must be typed by hand. If the line introducing a paragraph
2020-04-22 22:57:09 +00:00
is marked at the end with <span class="extract"><span class="ConsoleText-extract-syntax">^"Fun"</span></span>, then that paragraph will be tagged
as <span class="extract"><span class="ConsoleText-extract-syntax">Fun</span></span>, and so on. Paragraphs can have multiple tags:
2019-02-04 22:26:45 +00:00
</p>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> </span><span class="function-syntax">@</span><span class="plain-syntax"> ^"Algorithms" ^"History"</span>
<span class="plain-syntax"> The original version of the program used an in-place insertion sort, but</span>
<span class="plain-syntax"> ...</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">A tag can optionally supply a caption. For example:
2019-02-04 22:26:45 +00:00
</p>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> </span><span class="function-syntax">@</span><span class="plain-syntax"> ^"Algorithms: Sorting rulebooks"</span>
<span class="plain-syntax"> The original version of the program used an in-place insertion sort, but</span>
<span class="plain-syntax"> ...</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">Here the tag is just <span class="extract"><span class="extract-syntax">Algorithms</span></span>, but when a <span class="extract"><span class="extract-syntax">-weave-to Algorithms</span></span> is
2019-02-04 22:26:45 +00:00
performed, the caption text "Sorting rulebooks" will be used in a subheading
in the resulting booklet.
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">Beyond that, an entire section can be tagged from the <span class="extract"><span class="extract-syntax">Contents.w</span></span> page.
2019-02-04 22:26:45 +00:00
For example:
</p>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> Sections</span>
<span class="plain-syntax"> The Goldbach Conjecture</span>
<span class="plain-syntax"> The Sieve of Eratosthenes ^"Greek"</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">tags every paragraph in the section "The Sieve of Eratosthenes" with the
2020-04-22 22:57:09 +00:00
tag <span class="extract"><span class="extract-syntax">Greek</span></span>. In this instance, a caption is not allowed.
2019-02-04 22:26:45 +00:00
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">Note that if we <span class="extract"><span class="extract-syntax">-weave-to</span></span> a tag which does not exist - or rather, which no
2019-02-04 22:26:45 +00:00
paragraph in the range has - then rather than producing an empty document,
Inweb will halt with an "empty weave request" error.
</p>
2020-08-16 17:39:53 +00:00
<p class="commentary firstcommentary"><a id="SP14" class="paragraph-anchor"></a><b>&#167;14. Modules. </b>Up to now, the webs described have all been self-contained: one web makes
2019-02-04 22:26:45 +00:00
one program, and contains the code in its entirety. But Inweb also supports
"modules". A module is simply a web which provides a compoment of a program
but is not a program in its own right.
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">For example, all of the Inform tools (including Inweb itself) make use of
2020-04-22 22:57:09 +00:00
a module called <span class="extract"><span class="extract-syntax">foundation</span></span>, which is written in InC and provides
2019-02-04 22:26:45 +00:00
facilities for managing memory, manipulating strings, filenames, and so on.
2020-04-22 22:57:09 +00:00
On the other hand, the Inform project also includes a module called <span class="extract"><span class="extract-syntax">inter</span></span>
which is used only by the core compiler <span class="extract"><span class="extract-syntax">inform7</span></span> and by a wrapper utility
also called <span class="extract"><span class="extract-syntax">inter</span></span>; in fact, <span class="extract"><span class="extract-syntax">inform7</span></span> is entirely divided up into modules,
2019-02-04 22:26:45 +00:00
some of which are used only by itself.
</p>
2020-08-16 17:39:53 +00:00
<p class="commentary firstcommentary"><a id="SP15" class="paragraph-anchor"></a><b>&#167;15. </b>It makes little sense to tangle a module on its own. Instead, a web which
2020-04-22 22:57:09 +00:00
wishes to use a module needs to declare this on its <span class="extract"><span class="extract-syntax">Contents.w</span></span> page. This
2019-02-04 22:26:45 +00:00
is done with a list of "imports", after the metadata but before the list
of sections. For example,
</p>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> Import: foundation</span>
2020-04-07 22:04:32 +00:00
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> Chapter 1</span>
<span class="plain-syntax"> Startup</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">...and so on. When this new web is tangled, the module's code will tangled
2019-02-04 22:26:45 +00:00
into it. Any functions or variables defined in the module will thus be
available to the new web.
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">However, it makes perfectly good sense to weave a module. For example:
2019-02-04 22:26:45 +00:00
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb/Tangled/inweb</span><span class="ConsoleText-plain-syntax"> inweb/foundation-module</span><span class="ConsoleText-identifier-syntax"> -weave</span><span class="ConsoleText-plain-syntax"> sections</span>
</pre>
2020-08-16 17:39:53 +00:00
<p class="commentary firstcommentary"><a id="SP16" class="paragraph-anchor"></a><b>&#167;16. </b>That's everything there is to say about modules, except where Inweb looks
2020-04-22 22:57:09 +00:00
to find them. When it reads a request from a web <span class="extract"><span class="ConsoleText-extract-syntax">W</span></span> to import a module <span class="extract"><span class="ConsoleText-extract-syntax">M</span></span>,
it looks for a web directory called <span class="extract"><span class="ConsoleText-extract-syntax">M-module</span></span> (note the hyphen). For
example, <span class="extract"><span class="ConsoleText-extract-syntax">Import: fruit</span></span> would look for the directory <span class="extract"><span class="ConsoleText-extract-syntax">fruit-module</span></span>. Inweb
2019-02-04 22:26:45 +00:00
tries the following locations, in sequence, until it finds it:
</p>
2020-04-24 23:06:02 +00:00
<ul class="items"><li>(1) Directly inside <span class="extract"><span class="ConsoleText-extract-syntax">W</span></span>.
</li><li>(2) In the directory containing <span class="extract"><span class="ConsoleText-extract-syntax">W</span></span> (i.e., one directory higher up).
</li><li>(3) Directly inside Inweb's own web directory.
</li><li>(4) In the directory specified by <span class="extract"><span class="ConsoleText-extract-syntax">-import-from D</span></span> at the command line, if any.
</li></ul>
2020-08-16 17:39:53 +00:00
<p class="commentary firstcommentary"><a id="SP17" class="paragraph-anchor"></a><b>&#167;17. The section catalogue. </b>Inweb can do a handful of other things. One is to list the contents of a web:
</p>
2020-04-24 23:06:02 +00:00
<ul class="items"><li>(a) <span class="extract"><span class="ConsoleText-extract-syntax">-catalogue</span></span> (or <span class="extract"><span class="ConsoleText-extract-syntax">-catalog</span></span>) lists the sections in the web.
</li><li>(b) <span class="extract"><span class="ConsoleText-extract-syntax">-structures</span></span> lists the sections, and all of the structure definitions
2019-02-04 22:26:45 +00:00
made in them (for C-like languages).
2020-04-24 23:06:02 +00:00
</li><li>(c) <span class="extract"><span class="ConsoleText-extract-syntax">-functions</span></span> lists the sections, with all structure definitions and also
2019-02-04 22:26:45 +00:00
all function definitions.
2020-04-24 23:06:02 +00:00
</li></ul>
<p class="commentary">In addition, for debugging purposes, <span class="extract"><span class="ConsoleText-extract-syntax">-scan</span></span> shows how Inweb is parsing lines
2020-04-22 22:57:09 +00:00
of source code in the web, and <span class="extract"><span class="ConsoleText-extract-syntax">-verbose</span></span> makes it generally print out more
2019-02-04 22:26:45 +00:00
descriptive output.
</p>
2020-08-16 17:39:53 +00:00
<p class="commentary firstcommentary"><a id="SP18" class="paragraph-anchor"></a><b>&#167;18. Makefile. </b>As mentioned earlier, Inweb can construct a suitable makefile for a web:
2019-02-04 22:26:45 +00:00
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb/Tangled/inweb</span><span class="ConsoleText-plain-syntax"> W</span><span class="ConsoleText-identifier-syntax"> -makefile</span><span class="ConsoleText-plain-syntax"> M</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">creates a makefile for the web <span class="extract"><span class="ConsoleText-extract-syntax">W</span></span> and stores it in <span class="extract"><span class="ConsoleText-extract-syntax">M</span></span>. For example,
2019-02-04 22:26:45 +00:00
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb/Tangled/inweb</span><span class="ConsoleText-plain-syntax"> inweb</span><span class="ConsoleText-identifier-syntax"> -makefile</span><span class="ConsoleText-plain-syntax"> inweb/inweb.mk</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">The makefile is constructed using a prototype file called a "makescript".
2019-02-04 22:26:45 +00:00
Ordinarily the script used will be the one stored in
</p>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> W/makescript.txt</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">or, if no such file exists, the default one stored in Inweb:
2019-02-04 22:26:45 +00:00
</p>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> inweb/Materials/makescript.txt</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">but this can be changed by using <span class="extract"><span class="extract-syntax">-prototype S</span></span>, which tells Inweb to use
2020-04-22 22:57:09 +00:00
<span class="extract"><span class="extract-syntax">S</span></span> as the script. If a <span class="extract"><span class="extract-syntax">-prototype</span></span> is given, then there's no need to
2019-02-04 22:26:45 +00:00
specify any one web for Inweb to use: this allows Inweb to construct more
elaborate makefiles for multi-web projects. (This is how the main makefile
for the Inform project is constructed.)
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">To see how makescripts work, it's easiest simply to look at the default one.
2019-02-04 22:26:45 +00:00
</p>
2020-08-16 17:39:53 +00:00
<p class="commentary firstcommentary"><a id="SP19" class="paragraph-anchor"></a><b>&#167;19. Gitignore. </b>A similar convenience exists for users who want to use the git source control
2019-02-04 22:26:45 +00:00
tool with a web: for example, uploading it to Github.
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">The files produced by weaving or tangling a web are not significant and should
2019-02-04 22:26:45 +00:00
probably not be subject to source control: they should be "ignored", in git
2020-04-22 22:57:09 +00:00
terminology. This means writing a special file called <span class="extract"><span class="extract-syntax">.gitignore</span></span> which
specifies the files to be ignored. The following does so for a web <span class="extract"><span class="extract-syntax">W</span></span>:
2019-02-04 22:26:45 +00:00
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb/Tangled/inweb</span><span class="ConsoleText-plain-syntax"> W</span><span class="ConsoleText-identifier-syntax"> -gitignore</span><span class="ConsoleText-plain-syntax"> W/.gitignore</span>
2019-02-04 22:26:45 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">Once again, Inweb does this by working from a script, this time called
2020-04-22 22:57:09 +00:00
<span class="extract"><span class="ConsoleText-extract-syntax">gitignorescript.txt</span></span>.
2019-02-04 22:26:45 +00:00
</p>
2021-08-11 11:01:50 +00:00
<p class="commentary firstcommentary"><a id="SP20" class="paragraph-anchor"></a><b>&#167;20. Ctags. </b>Each time a web is tangled, Inweb writes a <span class="extract"><span class="ConsoleText-extract-syntax">tags</span></span> file to the web's home
directory, containing a list of <a href="https://ctags.io" class="external">Universal ctags</a>
for any structures, functions or constant definitions found in the web. You
need do nothing to make this happen, and can ignore the file if it's of no
use. If you are editing a web in certain text editors, though, such as
<a href="https://www.barebones.com/products/bbedit" class="external">BBEdit</a> for MacOS, then this
should make code completion and definition lookup features work.
</p>
<p class="commentary">You can however write the file elsewhere:
</p>
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb/Tangled/inweb</span><span class="ConsoleText-plain-syntax"> W</span><span class="ConsoleText-identifier-syntax"> -tangle -ctags-to</span><span class="ConsoleText-plain-syntax"> secret_lair/my_nifty.ctags</span>
</pre>
<p class="commentary">or not at all:
</p>
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb/Tangled/inweb</span><span class="ConsoleText-plain-syntax"> W</span><span class="ConsoleText-identifier-syntax"> -tangle -no-ctags</span>
</pre>
<p class="commentary firstcommentary"><a id="SP21" class="paragraph-anchor"></a><b>&#167;21. README files. </b>Repositories at Github customarily have <span class="extract"><span class="ConsoleText-extract-syntax">README.mk</span></span> files, in Markdown
2020-03-23 23:02:37 +00:00
syntax, explaining what they are. These of course should probably include
current version numbers, and it's a pain keeping that up to date. For
really complicated repositories, containing multiple webs, some automation
is essential, and once again Inweb can oblige.
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb/Tangled/inweb</span><span class="ConsoleText-plain-syntax"> W</span><span class="ConsoleText-identifier-syntax"> -write-me</span><span class="ConsoleText-plain-syntax"> W/README.mk</span>
2020-03-23 23:02:37 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">expands a script called <span class="extract"><span class="ConsoleText-extract-syntax">READMEscript.txt</span></span> into <span class="extract"><span class="ConsoleText-extract-syntax">README.mk</span></span>. Alternatively,
2020-03-23 23:02:37 +00:00
the script can be specified explicitly:
</p>
2020-04-25 10:33:39 +00:00
<pre class="ConsoleText-displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-element-syntax">$</span><span class="ConsoleText-plain-syntax"> </span><span class="ConsoleText-function-syntax">inweb/Tangled/inweb</span><span class="ConsoleText-plain-syntax"> W</span><span class="ConsoleText-identifier-syntax"> -prototype</span><span class="ConsoleText-plain-syntax"> MySpecialThang.txt</span><span class="ConsoleText-identifier-syntax"> -write-me</span><span class="ConsoleText-plain-syntax"> W/README.mk</span>
</pre>
2021-08-11 11:01:50 +00:00
<p class="commentary firstcommentary"><a id="SP22" class="paragraph-anchor"></a><b>&#167;22. </b>Everything in the script is copied over verbatim except where the <span class="extract"><span class="ConsoleText-extract-syntax">@</span></span> character
2020-03-23 23:02:37 +00:00
is used, which was chosen because it isn't significant in Github's form of
2020-04-22 22:57:09 +00:00
Markdown. <span class="extract"><span class="ConsoleText-extract-syntax">@name(args)</span></span> is like a function call (or, in more traditional
2020-03-23 23:02:37 +00:00
language, a macro): it expands out to something depending on the arguments.
2020-04-22 22:57:09 +00:00
<span class="extract"><span class="ConsoleText-extract-syntax">args</span></span> is a comma-separated list of fragments of text, which can themselves
contain further uses of <span class="extract"><span class="ConsoleText-extract-syntax">@</span></span>. (If these fragments of text need to contain
commas or brackets, they can be put into single quotes: <span class="extract"><span class="ConsoleText-extract-syntax">@thus(4,',')</span></span> has
two arguments, <span class="extract"><span class="ConsoleText-extract-syntax">4</span></span> and <span class="extract"><span class="ConsoleText-extract-syntax">,</span></span>.) Three functions are built in:
2020-03-23 23:02:37 +00:00
</p>
2020-04-24 23:06:02 +00:00
<ul class="items"><li>(a) <span class="extract"><span class="ConsoleText-extract-syntax">@version(A)</span></span> expands to the version number of <span class="extract"><span class="ConsoleText-extract-syntax">A</span></span>, which is normally the
2020-04-22 22:57:09 +00:00
path to a web; it then produces the value of the <span class="extract"><span class="ConsoleText-extract-syntax">[[Version Number]]</span></span> for
that web. But <span class="extract"><span class="ConsoleText-extract-syntax">A</span></span> can also be the filename of an Inform extension, provided
that it ends in <span class="extract"><span class="ConsoleText-extract-syntax">.i7x</span></span>, or a few other Inform-specific things for which
2020-03-23 23:02:37 +00:00
Inweb is able to deduce a version number.
2020-04-24 23:06:02 +00:00
</li><li>(b) <span class="extract"><span class="ConsoleText-extract-syntax">@purpose(A)</span></span> is the same, but for the <span class="extract"><span class="ConsoleText-extract-syntax">[[Purpose]]</span></span> of a web. It's
2020-03-23 23:02:37 +00:00
blank for everything else.
2020-04-24 23:06:02 +00:00
</li><li>(c) <span class="extract"><span class="ConsoleText-extract-syntax">@var(A,D)</span></span> is more general, and reads the bibliographic datum <span class="extract"><span class="ConsoleText-extract-syntax">D</span></span> from
2020-04-22 22:57:09 +00:00
the web indicated by <span class="extract"><span class="ConsoleText-extract-syntax">A</span></span>. In fact, <span class="extract"><span class="ConsoleText-extract-syntax">@version(A)</span></span> is an abbreviation for
<span class="extract"><span class="ConsoleText-extract-syntax">@var(A,Version Number)</span></span> and <span class="extract"><span class="ConsoleText-extract-syntax">@purpose(A)</span></span> for <span class="extract"><span class="ConsoleText-extract-syntax">@var(A,Purpose)</span></span>, so this
2020-03-23 23:02:37 +00:00
is really the only one needed.
2020-04-24 23:06:02 +00:00
</li></ul>
2021-08-11 11:01:50 +00:00
<p class="commentary firstcommentary"><a id="SP23" class="paragraph-anchor"></a><b>&#167;23. </b>It is also possible to define new functions. For example:
2020-04-20 22:26:08 +00:00
</p>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> @define book(title, path, topic)</span>
<span class="plain-syntax"> * @title - @topic. Ebook in Indoc format, stored at path @path.</span>
<span class="plain-syntax"> @end</span>
2020-03-23 23:02:37 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">The definition lies between <span class="extract"><span class="extract-syntax">@define</span></span> and <span class="extract"><span class="extract-syntax">@end</span></span> commands. This one takes
2020-03-23 23:02:37 +00:00
three parameters, and inside the definition, their values can be referred
2020-04-22 22:57:09 +00:00
to as <span class="extract"><span class="extract-syntax">@title</span></span>, <span class="extract"><span class="extract-syntax">@path</span></span> and <span class="extract"><span class="extract-syntax">@topic</span></span>. Functions are free to use other
2020-03-23 23:02:37 +00:00
functions:
</p>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> @define primary(program, language)</span>
<span class="plain-syntax"> * @program - @purpose(@program) - __@version(@program)__</span>
<span class="plain-syntax"> @end</span>
2020-03-23 23:02:37 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">However, each function needs to have been defined before any line on which
2020-04-22 22:57:09 +00:00
it is actually expanded. A definition of one function <span class="extract"><span class="extract-syntax">A</span></span> can refer to another
function <span class="extract"><span class="extract-syntax">B</span></span> not yet defined; but any actual use of <span class="extract"><span class="extract-syntax">A</span></span> must be made after
both <span class="extract"><span class="extract-syntax">A</span></span> and <span class="extract"><span class="extract-syntax">B</span></span> have been defined. So, basically, declare before use.
2020-03-23 23:02:37 +00:00
</p>
2021-08-11 11:01:50 +00:00
<p class="commentary firstcommentary"><a id="SP24" class="paragraph-anchor"></a><b>&#167;24. Semantic version numbering and build metadata. </b>When Inweb reads in a web, it also looks for a file called <span class="extract"><span class="extract-syntax">build.txt</span></span> in
2020-03-23 15:04:43 +00:00
the web's directory; if that isn't there, it looks for the same file in the
current working directory; if that's not there either, never mind.
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">Such a file contains up to three text fields, all optional:
2020-03-23 15:04:43 +00:00
</p>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> Prerelease: alpha.1</span>
<span class="plain-syntax"> Build Date: 23 March 2020</span>
<span class="plain-syntax"> Build Number: 6Q26</span>
2020-03-23 15:04:43 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">The bibliographic variables <span class="extract"><span class="extract-syntax">Prerelease</span></span> and so on are then set from this
2020-03-23 15:04:43 +00:00
file. (They can equally well be set by the Contents section of the web, and
if so then that takes priority.)
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">The Prerelease and Build Number, if given, are used in combination with the
2020-03-23 15:04:43 +00:00
Version Number (set in the Contents) to produce the semantic version number,
or semver, for the web. For example, if the Contents included:
</p>
2020-04-25 10:33:39 +00:00
<pre class="displayed-code all-displayed-code code-font">
2020-04-21 16:55:17 +00:00
<span class="plain-syntax"> Version Number: 6.2.12</span>
2020-03-23 15:04:43 +00:00
</pre>
2020-04-24 23:06:02 +00:00
<p class="commentary">then the semver would be <span class="extract"><span class="extract-syntax">6.2.12-alpha.1+6Q26</span></span>. This is accessible within
2020-04-22 22:57:09 +00:00
the web as the variable <span class="extract"><span class="extract-syntax">Semantic Version Number</span></span>.
2020-03-23 15:04:43 +00:00
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">For more on semvers, see: <a href="https://semver.org" class="external">https://semver.org</a>
2020-04-20 22:26:08 +00:00
</p>
2020-04-09 13:00:28 +00:00
2021-08-11 11:01:50 +00:00
<p class="commentary firstcommentary"><a id="SP25" class="paragraph-anchor"></a><b>&#167;25. </b>A special advancing mechanism exists to update build numbers and dates.
2020-04-22 22:57:09 +00:00
Running Inweb with <span class="extract"><span class="extract-syntax">-advance-build W</span></span> checks the build date for web <span class="extract"><span class="extract-syntax">W</span></span>:
2020-03-23 15:04:43 +00:00
if it differs from today, then it is changed to today, and the build code
is advanced by one.
</p>
2020-04-24 23:06:02 +00:00
<p class="commentary">Running <span class="extract"><span class="extract-syntax">-advance-build-file B</span></span> does this for a stand-alone build file <span class="extract"><span class="extract-syntax">B</span></span>,
2020-03-23 15:04:43 +00:00
without need of a web.
</p>
2020-04-30 22:36:38 +00:00
<nav role="progress"><div class="progresscontainer">
<ul class="progressbar"><li class="progressprev"><a href="M-iti.html">&#10094;</a></li><li class="progresscurrentchapter">M</li><li class="progresssection"><a href="M-iti.html">iti</a></li><li class="progresscurrent">wtaw</li><li class="progresssection"><a href="M-htwaw.html">htwaw</a></li><li class="progresssection"><a href="M-mwiw.html">mwiw</a></li><li class="progresssection"><a href="M-awwp.html">awwp</a></li><li class="progresssection"><a href="M-spl.html">spl</a></li><li class="progresssection"><a href="M-tid.html">tid</a></li><li class="progresssection"><a href="M-rc.html">rc</a></li><li class="progresschapter"><a href="P-htpw.html">P</a></li><li class="progresschapter"><a href="1-bsc.html">1</a></li><li class="progresschapter"><a href="2-tr.html">2</a></li><li class="progresschapter"><a href="3-ta.html">3</a></li><li class="progresschapter"><a href="4-pl.html">4</a></li><li class="progresschapter"><a href="5-wt.html">5</a></li><li class="progresschapter"><a href="6-mkf.html">6</a></li><li class="progressnext"><a href="M-htwaw.html">&#10095;</a></li></ul></div>
</nav><!--End of weave-->
2020-04-23 22:23:44 +00:00
</main>
2019-02-04 22:26:45 +00:00
</body>
</html>