Updating comments.

This commit is contained in:
Neil Edelman 2018-03-18 22:57:28 -04:00
parent 2e608d2f45
commit 988d7280d8
10 changed files with 498 additions and 32 deletions

View File

@ -44,16 +44,16 @@ Copyright 2008, 2012 Neil Edelman, distributed under the terms of the
GNU General Public License, see copying.txt GNU General Public License, see copying.txt
</p> </p>
<p> <p>
<em>Recusor</em> is the main part of <em>MakeIndex</em>, a content management system that <em>Recursor</em> is the main part of <em>MakeIndex</em>, a content management system that
generates static content, (mostly index.html,) on all the directories rooted generates static content, (mostly index.html,) on all the directories rooted
at the directory specified by the argument. It is based on a template file, at the directory specified by <em>--directory</em> or <em>-d</em>. It is based on a template
".index.html" and ".newsfeed.rss". Also included are files to summarise the file, <em>.index.html</em> and <em>.newsfeed.rss</em>, which are changeable. Also included
directory structure for a <em>xml</em> site map, compatible with Google, and any are files to summarise the directory structure for a <em>xml</em> site map,
<em>.news</em> for an <em>rss</em> feed. compatible with Google, and any <em>.news</em> for an <em>rss</em> feed.
</p> </p>
<p> <p>
There should be an &lt;example&gt; directory that has a bunch of files in it. Run There should be an &lt;example&gt; directory that has a bunch of files in it. Run
<em>bin/MakeIndex example/</em>; it should make a webpage out of the directory <em>bin/MakeIndex -d example/</em>; it should make a webpage out of the directory
structure and <em>.index.html</em>, open <em>example/index.html</em> after running to see. structure and <em>.index.html</em>, open <em>example/index.html</em> after running to see.
</p> </p>
<ul> <ul>
@ -97,8 +97,8 @@ treats <em>.link</em> as a link with the href in the file.
<p> <p>
<em>.index.html</em>, <em>.sitemap.xml</em>, <em>.newsfeed.rss</em>, see <em>Parser</em> for recognised <em>.index.html</em>, <em>.sitemap.xml</em>, <em>.newsfeed.rss</em>, see <em>Parser</em> for recognised
symbols. Assumes '..' is the parent directory, '.' is the current directory, symbols. Assumes '..' is the parent directory, '.' is the current directory,
and '/' is the directory separator; works for UNIX, MacOS, Windows. and '/' is the directory separator; works for UNIX, MacOS, and Windows. If
If this is not the case, the constants are in <em>Files.c</em>. this is not the case, the constants are in <em>Files.c</em>.
</p> </p>
<dl> <dl>
<dt>minimum standard</dt> <dt>minimum standard</dt>
@ -106,20 +106,23 @@ If this is not the case, the constants are in <em>Files.c</em>.
<dt>author</dt> <dt>author</dt>
<dd>Neil</dd> <dd>Neil</dd>
<dt>version</dt> <dt>version</dt>
<dd>1.1; 2017-03 fixed pedantic warnings; command-line improvements</dd> <dd>2018-03 Removed version numbers.</dd>
<dt>since</dt> <dt>since</dt>
<dd>1.0; 2016-09-19 Added umask <dd>1.1; 2017-03 Fixed pedantic warnings; command-line improvements.
0.8; 2013-07 case-insensitive sort 1.0; 2016-09-19 Added umask.
0.7; 2012 sth.dsth.d handled properly 0.8; 2013-07 Case-insensitive sort.
0.6; 2008-03-27</dd> 0.7; 2012 <em>sth.dsth.d</em> handled properly.
0.6; 2008-03-27 Made something out of an earlier work.</dd>
<dt>fixme</dt> <dt>fixme</dt>
<dd>Don't have &lt;directory&gt; be an argument; just do it in the current.</dd> <dd>Don't have &lt;directory&gt; be an argument; just do it in the current.</dd>
<dt>fixme</dt> <dt>fixme</dt>
<dd>Have a subset of LaTeX converted into html for the .d files?</dd> <dd>Borrow <em>Cdoc</em> parser for the <em>.d</em> files.</dd>
<dt>fixme</dt> <dt>fixme</dt>
<dd>Encoding is an issue; especially the newsfeed, which requires 7-bit.</dd> <dd>Encoding is an issue; especially the newsfeed, which requires 7-bit.</dd>
<dt>fixme</dt> <dt>fixme</dt>
<dd>It's not robust; eg @(files)<em>@(files){Don't do this.}</em>.</dd> <dd>It's not robust; eg @(files)<em>@(files){Don't do this.}</em>.</dd>
<dt>fixme</dt>
<dd>Simplify the command line arguments.</dd>
</dl> </dl>

View File

@ -1,15 +1,15 @@
/** Copyright 2008, 2012 Neil Edelman, distributed under the terms of the /** Copyright 2008, 2012 Neil Edelman, distributed under the terms of the
GNU General Public License, see copying.txt GNU General Public License, see copying.txt
{Recusor} is the main part of {MakeIndex}, a content management system that {Recursor} is the main part of {MakeIndex}, a content management system that
generates static content, (mostly index.html,) on all the directories rooted generates static content, (mostly index.html,) on all the directories rooted
at the directory specified by the argument. It is based on a template file, at the directory specified by {--directory} or {-d}. It is based on a template
".index.html" and ".newsfeed.rss". Also included are files to summarise the file, {.index.html} and {.newsfeed.rss}, which are changeable. Also included
directory structure for a {xml} site map, compatible with Google, and any are files to summarise the directory structure for a {xml} site map,
{.news} for an {rss} feed. compatible with Google, and any {.news} for an {rss} feed.
There should be an <example> directory that has a bunch of files in it. Run There should be an <example> directory that has a bunch of files in it. Run
{bin/MakeIndex example/}; it should make a webpage out of the directory {bin/MakeIndex -d example/}; it should make a webpage out of the directory
structure and {.index.html}, open {example/index.html} after running to see. structure and {.index.html}, open {example/index.html} after running to see.
* If the {.index.html} file exists in the <directory>, prints <index.html> * If the {.index.html} file exists in the <directory>, prints <index.html>
@ -32,21 +32,23 @@
{.index.html}, {.sitemap.xml}, {.newsfeed.rss}, see {Parser} for recognised {.index.html}, {.sitemap.xml}, {.newsfeed.rss}, see {Parser} for recognised
symbols. Assumes '..' is the parent directory, '.' is the current directory, symbols. Assumes '..' is the parent directory, '.' is the current directory,
and '/' is the directory separator; works for UNIX, MacOS, Windows. and '/' is the directory separator; works for UNIX, MacOS, and Windows. If
If this is not the case, the constants are in {Files.c}. this is not the case, the constants are in {Files.c}.
@title Recursor @title Recursor
@author Neil @author Neil
@std POSIX.1 @std POSIX.1
@version 1.1; 2017-03 fixed pedantic warnings; command-line improvements @version 2018-03 Removed version numbers.
@since 1.0; 2016-09-19 Added umask @since 1.1; 2017-03 Fixed pedantic warnings; command-line improvements.
0.8; 2013-07 case-insensitive sort 1.0; 2016-09-19 Added umask.
0.7; 2012 sth.dsth.d handled properly 0.8; 2013-07 Case-insensitive sort.
0.6; 2008-03-27 0.7; 2012 {sth.dsth.d} handled properly.
0.6; 2008-03-27 Made something out of an earlier work.
@fixme Don't have <directory> be an argument; just do it in the current. @fixme Don't have <directory> be an argument; just do it in the current.
@fixme Have a subset of LaTeX converted into html for the .d files? @fixme Borrow {Cdoc} parser for the {.d} files.
@fixme Encoding is an issue; especially the newsfeed, which requires 7-bit. @fixme Encoding is an issue; especially the newsfeed, which requires 7-bit.
@fixme It's not robust; eg @(files){@(files){Don't do this.}}. */ @fixme It's not robust; eg @(files){@(files){Don't do this.}}.
@fixme Simplify the command line arguments. */
#include <stdlib.h> /* malloc free fgets */ #include <stdlib.h> /* malloc free fgets */
#include <stdio.h> /* fprintf FILE */ #include <stdio.h> /* fprintf FILE */
@ -65,7 +67,6 @@ static const int version_major = 1;
static const int version_minor = 1; static const int version_minor = 1;
static const size_t granularity = 1024; static const size_t granularity = 1024;
static const int max_read = 0x1000;
static const char *html_index = "index.html"; static const char *html_index = "index.html";
static const char *xml_sitemap = "sitemap.xml"; static const char *xml_sitemap = "sitemap.xml";
static const char *rss_newsfeed = "newsfeed.rss"; static const char *rss_newsfeed = "newsfeed.rss";
@ -315,7 +316,7 @@ static void usage(void) {
"under certain conditions; see gpl.txt.\n\n"); "under certain conditions; see gpl.txt.\n\n");
} }
/* entry-point (shouldn't have a prototype) */ /* Entry-point (shouldn't have a prototype.) */
int main(int argc, char **argv) { int main(int argc, char **argv) {
int ac, ret; int ac, ret;
int is_help = 0, is_invalid = 0; int is_help = 0, is_invalid = 0;
@ -375,7 +376,7 @@ int main(int argc, char **argv) {
if(is_help || !directory) { if(is_help || !directory) {
usage(); usage();
return is_help && !is_invalid ? EXIT_SUCCESS : EXIT_FAILURE; return is_help || !is_invalid ? EXIT_SUCCESS : EXIT_FAILURE;
} }
fprintf(stderr, "Changing directory to <%s>.\n", directory); fprintf(stderr, "Changing directory to <%s>.\n", directory);

1
web/MakeIndex.link Normal file
View File

@ -0,0 +1 @@
https://github.com/neil-edelman/MakeIndex

1
web/MakeIndex.link.d Normal file
View File

@ -0,0 +1 @@
The source repository is on <em>GitHub</em>.

248
web/Parser.html Normal file
View File

@ -0,0 +1,248 @@
<!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<!-- steal these colour values from JavaDocs; meh -->
<style type = "text/css">
a:link, a:visited { color: #4a6782; }
a:hover, a:focus { color: #bb7a2a; }
a:active { color: #4A6782; }
tr:nth-child(even) { background: #dee3e9; }
div {
margin: 4px 0;
padding: 0 4px 4px 4px;
}
table { width: 100%; }
td { padding: 4px; }
h3, h1 {
color: #2c4557;
background-color: #dee3e9;
padding: 4px;
}
h3 {
margin: 0 -4px;
padding: 4px;
}
</style>
<title>Parser</title>
</head>
<body>
<h1>Parser</h1>
<ul>
<li><a href = "#_declarations">Declarations</a></li>
<li><a href = "#_summary">Function Summary</a></li>
<li><a href = "#_detail">Function Detail</a></li>
</ul>
<p>
Copyright 2008, 2012 Neil Edelman, distributed under the terms of the
GNU General Public License, see copying.txt
</p>
<p>
Parsing of strings. '~' on a line by itself is recognised in ".newsfile.rss"
and ".sitemap.xml" as a &lt;head&gt;~&lt;body&gt;~&lt;tail&gt;; there should be two of them.
</p>
<p>
Parsed in ".index.html",
</p>
<ul>
<li>
@(content) prints <em>content.d</em>, or, if it is missing, <em>index.d</em>;
</li>
<li>
@(files){} repeats for all the files in the directory the contents of the
argument;
</li>
<li>
@(htmlcontent);
</li>
<li>
@(pwd){} prints the directory, the argument is the separator;
eg, @(pwd){/};
</li>
<li>
@(root){}, like @(pwd), except up instead of down;
</li>
<li>
@(now) prints the date and the time in UTC.
</li>
</ul>
<p>
Further parsed in @(files)<em></em> in ".index.html",
</p>
<ul>
<li>
@(filealt) prints Dir or File;
</li>
<li>
@(filedesc);
</li>
<li>
@(filehref) prints the filename or the <em>.link</em>;
</li>
<li>
@(fileicon) prints it's <em>.d.jpeg</em>, or if it is not there, <em>dir.jpeg</em> or
<em>file.jpeg</em>;
</li>
<li>
@(filename) prints the file name;
</li>
<li>
@(filesize) prints the file size, if it exits;
</li>
<li>
@(now) prints the date and the time in UTC.
</li>
</ul>
<p>
Parsed in ".newsfeed.rss",
</p>
<ul>
<li>
@(date) prints the date on the news file;
</li>
<li>
@(news) prints the contents of the file (as a text file);
</li>
<li>
@(newsname) prints the filename of the news story;
</li>
<li>
@(now) prints the date and the time in UTC;
</li>
<li>
@(title) prints the second line in the <em>.news</em>.
</li>
</ul>
<dl>
<dt>minimum standard</dt>
<dd>C89/90</dd>
<dt>author</dt>
<dd>Neil</dd>
<dt>version</dt>
<dd>1.1; 2017-03 fixed pedantic warnings; command-line improvements</dd>
<dt>since</dt>
<dd>0.6; 2008-03-21</dd>
</dl>
<a name = "_declarations"><!-- --></a><h2>Declarations</h2>
<div><a name = "struct Parser"><!-- --></a>
<h3>struct Parser</h3>
<pre><b>struct Parser</b></pre>
<p>
See <a href = "#Parser">Parser</a>.
</p>
<dl>
</dl>
</div>
<div><a name = "struct Files"><!-- --></a>
<h3>struct Files</h3>
<pre><b>struct Files</b></pre>
<p>
Dependancy on <em>Files</em>.
</p>
<dl>
</dl>
</div>
<div><a name = "typedef int (*ParserWidget)(struct Files *const files, FILE *const fp)"><!-- --></a>
<h3>typedef int (*ParserWidget)(struct Files *const files, FILE *const fp)</h3>
<pre><b>typedef int (*ParserWidget)(struct Files *const files, FILE *const fp)</b></pre>
<p>
All <em>ParserWidget</em>s are in <em>Widget.c</em>.
</p>
<dl>
</dl>
</div>
<a name = "_summary"><!-- --></a><h2>Function Summary</h2>
<table>
<tr><th>Return Type</th><th>Function Name</th><th>Argument List</th></tr>
<tr>
<td>struct Parser *</td>
<td><a href = "#Parser">Parser</a></td>
<td>char *const str</td>
</tr>
<tr>
<td>void</td>
<td><a href = "#Parser_">Parser_</a></td>
<td>struct Parser **const p_ptr</td>
</tr>
<tr>
<td>void</td>
<td><a href = "#ParserRewind">ParserRewind</a></td>
<td>struct Parser *p</td>
</tr>
<tr>
<td>int</td>
<td><a href = "#ParserParse">ParserParse</a></td>
<td>struct Parser *p, struct Files *const f, int invisible,
FILE *fp</td>
</tr>
</table>
<a name = "_detail"><!-- --></a><h2>Function Detail</h2>
<div><a name = "Parser"><!-- --></a>
<h3>Parser</h3>
<pre>struct Parser * <b>Parser</b> (char *const str)</pre>
<dl>
<dt>return</dt>
<dd>Creates a parser for the string, <em>str</em>.</dd>
</dl>
</div>
<div><a name = "Parser_"><!-- --></a>
<h3>Parser_</h3>
<pre>void <b>Parser_</b> (struct Parser **const p_ptr)</pre>
<dl>
<dt>parameter: p_ptr</dt>
<dd>A pointer to the <em>Parser</em> that's to be destucted.</dd>
</dl>
</div>
<div><a name = "ParserRewind"><!-- --></a>
<h3>ParserRewind</h3>
<pre>void <b>ParserRewind</b> (struct Parser *p)</pre>
<p>
Resets the parser, <em>p</em>.
</p>
<dl>
</dl>
</div>
<div><a name = "ParserParse"><!-- --></a>
<h3>ParserParse</h3>
<pre>int <b>ParserParse</b> (struct Parser *p, struct Files *const f, int invisible,
FILE *fp)</pre>
<p>
Parse, called recursively.
</p>
<dl>
<dt>parameter: f</dt>
<dd>Called in the handler to <em>ParserWidget</em>s.</dd>
<dt>parameter: invisible</dt>
<dd>No output.</dd>
<dt>parameter: fp</dt>
<dd>Output.</dd>
<dt>fixme</dt>
<dd>This fn needs rewriting; messy.</dd>
<dt>fixme</dt>
<dd>Invisible, hack.</dd>
</dl>
</div>
</body>
</html>

2
web/Parser.html.d Normal file
View File

@ -0,0 +1,2 @@
Auto-generated file that tells you how to do a <em>.index.html</em>,
<em>etc</em>.

201
web/Recursor.html Normal file
View File

@ -0,0 +1,201 @@
<!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<!-- steal these colour values from JavaDocs; meh -->
<style type = "text/css">
a:link, a:visited { color: #4a6782; }
a:hover, a:focus { color: #bb7a2a; }
a:active { color: #4A6782; }
tr:nth-child(even) { background: #dee3e9; }
div {
margin: 4px 0;
padding: 0 4px 4px 4px;
}
table { width: 100%; }
td { padding: 4px; }
h3, h1 {
color: #2c4557;
background-color: #dee3e9;
padding: 4px;
}
h3 {
margin: 0 -4px;
padding: 4px;
}
</style>
<title>Recursor</title>
</head>
<body>
<h1>Recursor</h1>
<ul>
<li><a href = "#_declarations">Declarations</a></li>
<li><a href = "#_summary">Function Summary</a></li>
<li><a href = "#_detail">Function Detail</a></li>
</ul>
<p>
Copyright 2008, 2012 Neil Edelman, distributed under the terms of the
GNU General Public License, see copying.txt
</p>
<p>
<em>Recursor</em> is the main part of <em>MakeIndex</em>, a content management system that
generates static content, (mostly index.html,) on all the directories rooted
at the directory specified by <em>--directory</em> or <em>-d</em>. It is based on a template
file, <em>.index.html</em> and <em>.newsfeed.rss</em>, which are changeable. Also included
are files to summarise the directory structure for a <em>xml</em> site map,
compatible with Google, and any <em>.news</em> for an <em>rss</em> feed.
</p>
<p>
There should be an &lt;example&gt; directory that has a bunch of files in it. Run
<em>bin/MakeIndex -d example/</em>; it should make a webpage out of the directory
structure and <em>.index.html</em>, open <em>example/index.html</em> after running to see.
</p>
<ul>
<li>
If the <em>.index.html</em> file exists in the &lt;directory&gt;, prints &lt;index.html&gt;
recursively; overwrites any <em>index.html</em> on all the directories rooted at
&lt;directory&gt;;
</li>
<li>
if the <em>.sitemap.xml</em> file exists in &lt;directory&gt;, prints (and overwrites) an
index called <em>sitemap.xml</em>;
</li>
<li>
if the <em>.newsfeed.rss</em> file exists in &lt;directory&gt;, prints (and overwrites)
to <em>newsfeed.rss</em> all the <em>.news</em> files (if there are any.)
</li>
</ul>
<ul>
<li>
Treats <em>.d</em> as a description of the file without the <em>.d</em>;
if this is an empty text-file or a zero-byte file, it skips over this file.
</li>
<li>
treats <em>index.d</em> as a description of the directory;
</li>
<li>
treats <em>content.d</em> as an in-depth description of the directory,
replacing &lt;index.d&gt; when in the directory;
</li>
<li>
treats <em>.d.jpg</em> as a image that will go with the description;
</li>
<li>
treats <em>.news</em> as a newsworthy item; the format of this file is ISO 8601
date (YYYY-MM-DD,) next line title;
</li>
<li>
treats <em>.link</em> as a link with the href in the file.
</li>
</ul>
<p>
<em>.index.html</em>, <em>.sitemap.xml</em>, <em>.newsfeed.rss</em>, see <em>Parser</em> for recognised
symbols. Assumes '..' is the parent directory, '.' is the current directory,
and '/' is the directory separator; works for UNIX, MacOS, and Windows. If
this is not the case, the constants are in <em>Files.c</em>.
</p>
<dl>
<dt>minimum standard</dt>
<dd>POSIX.1</dd>
<dt>author</dt>
<dd>Neil</dd>
<dt>version</dt>
<dd>2018-03 Removed version numbers.</dd>
<dt>since</dt>
<dd>1.1; 2017-03 Fixed pedantic warnings; command-line improvements.
1.0; 2016-09-19 Added umask.
0.8; 2013-07 Case-insensitive sort.
0.7; 2012 <em>sth.dsth.d</em> handled properly.
0.6; 2008-03-27 Made something out of an earlier work.</dd>
<dt>fixme</dt>
<dd>Don't have &lt;directory&gt; be an argument; just do it in the current.</dd>
<dt>fixme</dt>
<dd>Borrow <em>Cdoc</em> parser for the <em>.d</em> files.</dd>
<dt>fixme</dt>
<dd>Encoding is an issue; especially the newsfeed, which requires 7-bit.</dd>
<dt>fixme</dt>
<dd>It's not robust; eg @(files)<em>@(files){Don't do this.}</em>.</dd>
<dt>fixme</dt>
<dd>Simplify the command line arguments.</dd>
</dl>
<a name = "_declarations"><!-- --></a><h2>Declarations</h2>
<div><a name = "struct Recursor"><!-- --></a>
<h3>struct Recursor</h3>
<pre><b>struct Recursor</b></pre>
<p>
See <a href = "#Recursor">Recursor</a>.
</p>
<dl>
</dl>
</div>
<a name = "_summary"><!-- --></a><h2>Function Summary</h2>
<table>
<tr><th>Return Type</th><th>Function Name</th><th>Argument List</th></tr>
<tr>
<td>struct Recursor *</td>
<td><a href = "#Recursor">Recursor</a></td>
<td>const char *idx, const char *map, const char *news</td>
</tr>
<tr>
<td>void</td>
<td><a href = "#Recursor_">Recursor_</a></td>
<td>void</td>
</tr>
<tr>
<td>int</td>
<td><a href = "#RecursorGo">RecursorGo</a></td>
<td>void</td>
</tr>
</table>
<a name = "_detail"><!-- --></a><h2>Function Detail</h2>
<div><a name = "Recursor"><!-- --></a>
<h3>Recursor</h3>
<pre>struct Recursor * <b>Recursor</b> (const char *idx, const char *map, const char *news)</pre>
<dl>
<dt>parameter: idx</dt>
<dd>file name of the prototype index file, eg, ".index.html".</dd>
<dt>parameter: map</dt>
<dd>file name of the prototype map file, eg, ".sitmap.xml".</dd>
<dt>parameter: news</dt>
<dd>file name of the prototype news file, eg, ".newsfeed.rss".</dd>
</dl>
</div>
<div><a name = "Recursor_"><!-- --></a>
<h3>Recursor_</h3>
<pre>void <b>Recursor_</b> (void)</pre>
<p>
Destructor.
</p>
<dl>
</dl>
</div>
<div><a name = "RecursorGo"><!-- --></a>
<h3>RecursorGo</h3>
<pre>int <b>RecursorGo</b> (void)</pre>
<p>
Actually does the recursion.
</p>
<dl>
</dl>
</div>
</body>
</html>

1
web/Recursor.html.d Normal file
View File

@ -0,0 +1 @@
Auto-generated documentation for the main programme.

7
web/content.d Normal file
View File

@ -0,0 +1,7 @@
MakeIndex is a content management system that generates static
content. Notably, I use it to make this page. It does some other
stuff, too, like summarise the directory structure in an <em>xml</em>
site map that is compatible with Google, and any <em>.news</em> in
an <em>rss</em> feed. The source code is <em>POSIX.1</em>, so in
Windows, one needs to compile it with <em>DJGPP</em>, <em>MinGW</em>,
<em>etc</em>, and probably not <em>MSVC</em>.

1
web/index.d Normal file
View File

@ -0,0 +1 @@
Static content management system.