App::DocKnot::Spin::Pointer - Generate HTML from a pointer to an external file
use App::DocKnot::Spin::Pointer;
use App::DocKnot::Spin::Sitemap;
use Path::Tiny qw(path);
my $sitemap_path = path('/input/.sitemap');
my $sitemap = App::DocKnot::Spin::Sitemap->new($sitemap_path);
my $pointer = App::DocKnot::Spin::Pointer->new({
output => path('/output'),
sitemap => $sitemap,
});
my $input = path('/input/file.spin');
my $output = path('/output/file.html');
$pointer->spin_pointer($input, $output);
Perl 5.24 or later and the modules File::ShareDir, Kwalify, List::SomeUtils,
Path::Tiny, Pod::Thread, and YAML::XS, all of which are available from CPAN.
The tree of input files for App::DocKnot::Spin may contain pointers to external
files in various formats. These files are in YAML format and end in
".spin". This module processes those files and converts them to HTML
and, if so configured, adds the links to integrate the page with the rest of
the site.
For the details of the pointer file format, see "POINTER FILES" below.
- new(ARGS)
- Create a new App::DocKnot::Spin::Pointer object. A single
converter object can be used repeatedly to convert pointers in a tree of
files. ARGS should be a hash reference with one or more of the following
keys, all of which are optional:
- output
- The path to the root of the output tree when converting a
tree of files. This will be used to calculate relative path names for
generating inter-page links using the provided "sitemap"
argument. If "sitemap" is given, this option should also always
be given.
- sitemap
- An App::DocKnot::Spin::Sitemap object. This will be used to
create inter-page links. For inter-page links, the "output"
argument must also be provided.
- style-url
- The base URL for style sheets. A style sheet specified in a
pointer file will be considered to be relative to this URL and this URL
will be prepended to it. If this option is not given, the name of the
style sheet will be used verbatim as its URL, except with ".css"
appended.
- thread
- An App::DocKnot::Spin::Thread object, used for converting
POD into HTML. It should be configured with the same
App::DocKnot::Spin::Sitemap object as the "sitemap"
argument.
- is_out_of_date(POINTER, OUTPUT)
- Returns true if OUTPUT is missing or if it was modified
less recently than the modification time of either POINTER or the
underlying file that it points to. Both paths must be Path::Tiny
objects.
- spin_pointer(POINTER, OUTPUT)
- Convert a single pointer file to HTML. POINTER is the path
to the pointer file, and OUTPUT is the path to where to write the output.
Both paths must be Path::Tiny objects.
A pointer file is a YAML file ending in ".spin" that points to the
source file for a generated HTML page and provides additional configuration
for its conversion. The valid keys for a pointer file are:
- format
- The format of the source file. Supported values are
"markdown" and "pod". Required.
- path
- The path to the source file. It may be relative, in which
case it's relative to the pointer file. Required.
- options
- Additional options that control the conversion to HTML.
These will be different for each supported format.
"markdown" has no supported options.
The supported options for a format of "pod" are:
- contents
- Boolean saying whether to generate a table of contents. The
default is false.
- navbar
- Boolean saying whether to generate a navigation bar at the
top of the page. The default is true.
- style
- The style sheet to use for the converted output. Optional.
If not set, converted "markdown" output will be unstyled and
converted "pod" output will use a style sheet named
"pod".
- title
- The title of the converted page. Optional. If not set, the
title will be taken from the converted file in a format-specific way. For
Markdown, the title will be the contents of the first top-level heading.
For POD, the title will be taken from a NAME section formatted according
to the conventions for manual pages.
Russ Allbery <
[email protected]>
Copyright 2021 Russ Allbery <
[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
docknot(1), App::DocKnot::Spin, App::DocKnot::Spin::Sitemap
This module is part of the App-DocKnot distribution. The current version of
DocKnot is available from CPAN, or directly from its web site at
<
https://www.eyrie.org/~eagle/software/docknot/>.