about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-09-20 16:26:43 +0200
committerbptato <nincsnevem662@gmail.com>2023-09-20 16:27:05 +0200
commite746fcf957239d5e9210fdc6bad333fa9e1a7364 (patch)
tree6aed2ed0560a65ffb508632c4a6b482a5aa1cb80
parent29802269045c5eeb137a85d067120c5c6c7a6ed2 (diff)
downloadchawan-e746fcf957239d5e9210fdc6bad333fa9e1a7364.tar.gz
add manpages
still needs some work
-rw-r--r--Makefile11
-rw-r--r--doc/cha.1123
-rw-r--r--doc/config.md6
3 files changed, 139 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 9bb3a1a3..942e2f09 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,9 @@ OBJDIR = .obj
 FLAGS = -o:cha -d:curlLibName:$(CURLLIBNAME)
 FILES = src/main.nim
 prefix = /usr/local
+manprefix = /usr/local/share/man
+manprefix1 = $(manprefix)/man1
+manprefix5 = $(manprefix)/man5
 QJSOBJ = $(OBJDIR)/quickjs
 CFLAGS = -g -Wall -O2 -DCONFIG_VERSION=\"$(shell cat lib/quickjs/VERSION)\"
 
@@ -46,10 +49,18 @@ clean:
 	rm -rf $(OBJDIR)
 	rm -f lib/libquickjs.a
 
+.PHONY: manpage
+manpage:
+	sed '/<!-- TOCSTART -->/,/<!-- TOCEND -->/d' doc/config.md > .obj/cha-config.md
+	pandoc --standalone --to man .obj/cha-config.md -o .obj/cha-config.5
+	cp doc/cha.1 "$(OBJDIR)/cha.1"
+
 .PHONY: install
 install:
 	mkdir -p "$(DESTDIR)$(prefix)/bin"
 	install -m755 cha "$(DESTDIR)$(prefix)/bin"
+	test -f "$(OBJDIR)/cha-config.5" && install -m755 "$(OBJDIR)/cha-config.5" "$(DESTDIR)$(manprefix5)"
+	test -f "$(OBJDIR)/cha.1" && install -m755 "$(OBJDIR)/cha.1" "$(DESTDIR)$(manprefix1)"
 
 .PHONY: uninstall
 uninstall:
diff --git a/doc/cha.1 b/doc/cha.1
new file mode 100644
index 00000000..dcb32baf
--- /dev/null
+++ b/doc/cha.1
@@ -0,0 +1,123 @@
+.TH CHA 1
+.SH NAME
+cha - the Chawan text-mode browser
+.SH SYNOPSIS
+.B cha
+[\fBoptions\fR]
+[\fIURL(s) \fRor \fIfile(s)\fR...]
+.SH DESCRIPTION
+Chawan is a text-mode browser. It can be used as a pager, or as a
+web/FTP/gopher/file browser, and understands HTML, CSS and JavaScript.
+Chawan can also be used to as a general text-based document viewer using
+\fBmailcap\fR(5) extensions.
+
+Like \fBw3m\fR(1), Chawan organizes files and pages into buffers. The user
+can freely open, duplicate, delete, and navigate between these.
+
+.SH ARGUMENTS
+On invocation, Chawan looks through all arguments provided, and attempts
+to open each file supplied. An error message is provided if opening a file
+fails. If no files could successfully be opened, Chawan exits automatically.
+
+Chawan may also be started without specifying a file, if a file is provided
+through a pipe. In this case, it may be useful to set the content type using
+e.g. \fB\-T \fItext/html\fR. (The \fB-\fR pseudo-file argument, commonly accepted
+by other commands, is simply ignored.)
+
+.SH OPTIONS
+Command line options generally have both short forms (e.g. \fB\-d\fR) and long
+forms (e.g. \fB\-\-dump\fR).
+
+Long forms must be introduced with two dashes; when
+only a single dash is provided, each letter is parsed as a separate short form.
+.br
+(e.g. \fB\-abcd\fR is equivalent to \fB\-a \-b \-c \-d\fR, \fInot\fR
+\fB\-\-abcd\fR.)
+
+.TP
+\fB\-d, \-\-dump\fR
+Start in headless mode, and sequentially print the opened files to stdout.
+This option is implicitly enabled if stdout is not a tty (e.g. when piping
+\fIcha\fR output).
+.TP
+\fB\-o, \-\-opt\fR \fIconfig\fR
+Override configuration options. This accepts the configuration format is
+described in \fBcha-config\fR(5), in other words the passed string must be
+valid TOML.
+
+(The sole exception is quoting: to ease specifying string
+parameters, unrecognized bare keywords are converted to strings. So this
+works: \fB--opt\fR \fIabcd.option-name\fR=\fIoption-value\fR. However, symbols must
+still be quoted.)
+.TP
+\fB\-c, \-\-css\fR \fIstylesheet\fR
+Temporarily modify the user stylesheet. If a user stylesheet is already
+being used, the stylesheet given is appended to that.
+.TP
+\fB\-T, \-\-type\fR \fIcontent-type\fR
+Override the content type of all input files. Useful when the content type
+cannot be guessed from the file extension, or when reading a non-plaintext
+file from stdin.
+.TP
+\fB\-I, \-\-input-charset\fR \fIcharset\fR
+Override the character set of all input files. Useful when Chawan is
+incorrectly recognizing the input character set. (Note: if this happens
+often, consider changing the default input charset recognition list
+\fIencoding.document-charset\fR in the configuration.)
+.TP
+\fB\-O, \-\-output-charset\fR \fIcharset\fR
+Override the output character set. This is a shortcut for
+\fB\-o \fIencoding.display\-charset\fR=\fIcharset\fR.
+.TP
+\fB\-M, \-\-monochrome\fR
+Override the output character set. This is a shortcut for
+\fB\-o \fIdisplay.color\-mode\fR=\fIansi\fR.
+.TP
+\fB\-V, \-\-visual\fR
+Start in visual mode: the page specified in \fIstart.visual-home\fR is opened.
+.TP
+\fB\-r, \-\-run\fR \fIscript\fR/\fIfile\fR
+Execute the string provided as a JS script, or execute the supplied JS
+file. If the file ends in .mjs, it is executed as an ES module.
+.br
+(To execute an inline script as a module, the following hack can be used:
+.br
+\fIcha \fB-r \fR'await new Promise(x => setTimeout(x, 1000));
+console.log("hello from ESM!"); //.mjs'
+.br
+In other words, we add a comment \fI//.mjs\fR to the end of the script.)
+.TP
+\fB\-h, \-\-help\fR
+Print a short version of this page, then exit.
+.TP
+\fB\-v, \-\-version\fR
+Print information about the browser's version, then exit.
+.TP
+\fB\-\-\fP
+Interpret all following arguments as files. (e.g. if you have a file named
+\fI\-o\fR, open it as \fIcha \fB--\fR \fI-o\fR.
+
+.SH ENVIRONMENT VARIABLES
+Certain environment variables are read and used by Chawan.
+
+.TP
+\fBHTTP_HOME\fR, \fBWWW_HOME\fR
+When set, Chawan starts in visual mode by default and opens the page specified
+by one of these variables. (\fBHTTP_HOME\fR takes precedence over
+\fBWWW_HOME\fR.)
+.TP
+\fBCOLORTERM\fR
+When set to \fI24bit\fR or \fItruecolor\fR, and the \fIdisplay.color-mode\fR
+configuration option is set to \fIauto\fR, Chawan sets the color mode to
+true color.
+.TP
+\fBTERM\fR
+Used by Chawan to determine which termcap entry to load. When not set,
+defaults to \fIdosansi\fR.
+.TP
+\fBEDITOR\fR
+Used to determine the editor to use when the \fIexternal.editor\fR
+configuration option is not set.
+
+.SH CONFIGURATION
+Configuration options are described in \fBcha-config\fR(5).
diff --git a/doc/config.md b/doc/config.md
index 029f9a8a..2e989bd1 100644
--- a/doc/config.md
+++ b/doc/config.md
@@ -1,4 +1,6 @@
-# Configuration
+% cha-config(5) | Configuration of Chawan
+
+# Configuration of Chawan
 
 Chawan supports configuration of various options like keybindings, user
 stylesheets, site preferences, etc. The configuration format is very similar
@@ -21,6 +23,7 @@ environment variable is not set.) See the default configuration file in the
 res/ folder, and bonus configuration files in the bonus/ folder for further
 examples.
 
+<!-- TOCSTART -->
 **Table of contents**
 
 * [Start](#start)
@@ -38,6 +41,7 @@ examples.
 * [Appendix](#appendix)
    * [Regex handling](#regex-handling)
 
+<!-- TOCEND -->
 ## Start
 
 Start-up options are to be placed in the `[start]` section.