Commit f821d5e7 authored by Dan Allen's avatar Dan Allen

follow-up to #48 finish aligning variable names w/ architecture

- rename fragmentsdir to partialsdir
- rename fragment family to partial
- rename samplesdir to examplesdir
- rename sample family to example
- rename vfileCatalog to catalog
- rename vfiles to files
parent 49c3d6f5
Pipeline #14765625 passed with stages
in 3 minutes and 28 seconds
:attachmentsdir: {moduledir}/assets/attachments :attachmentsdir: {moduledir}/assets/attachments
:fragmentsdir: {moduledir}/documents/_fragments :exampesdir: {moduledir}/examples
:imagesdir: {moduledir}/assets/images :imagesdir: {moduledir}/assets/images
:samplesdir: {moduledir}/samples :partialsdir: {moduledir}/documents/_partials
...@@ -32,4 +32,4 @@ You'll then find out how to set it up and run it. ...@@ -32,4 +32,4 @@ You'll then find out how to set it up and run it.
== Pipeline steps == Pipeline steps
include::{fragmentsdir}/pipeline-steps-list.adoc[] include::{partialsdir}/pipeline-steps-list.adoc[]
:attachmentsdir: {moduledir}/assets/attachments :attachmentsdir: {moduledir}/assets/attachments
:fragmentsdir: {moduledir}/documents/_fragments :examplesdir: {moduledir}/examples
:imagesdir: {moduledir}/assets/images :imagesdir: {moduledir}/assets/images
:samplesdir: {moduledir}/samples :partialsdir: {moduledir}/documents/_partials
:attachmentsdir: {moduledir}/assets/attachments :attachmentsdir: {moduledir}/assets/attachments
:fragmentsdir: {moduledir}/documents/_fragments :examplesdir: {moduledir}/examples
:imagesdir: {moduledir}/assets/images :imagesdir: {moduledir}/assets/images
:samplesdir: {moduledir}/samples :partialsdir: {moduledir}/documents/_partials
...@@ -27,11 +27,11 @@ It will not be accurate until Antora is officially released. ...@@ -27,11 +27,11 @@ It will not be accurate until Antora is officially released.
== Playbook Repository == Playbook Repository
include::{fragmentsdir}/playbook-project-summary.adoc[] include::{partialsdir}/playbook-project-summary.adoc[]
== site.yml == site.yml
include::{fragmentsdir}/playbook-summary.adoc[] include::{partialsdir}/playbook-summary.adoc[]
//// ////
There's one playbook preconfigured in this project. There's one playbook preconfigured in this project.
......
...@@ -12,7 +12,7 @@ endif::[] ...@@ -12,7 +12,7 @@ endif::[]
*This page is for people joining a documentation project that already uses Antora.* *This page is for people joining a documentation project that already uses Antora.*
include::{fragmentsdir}/playbook-project-summary.adoc[] include::{partialsdir}/playbook-project-summary.adoc[]
Before you can run Antora on your own machine, you'll need to fetch the playbook project for your site and initialize it Before you can run Antora on your own machine, you'll need to fetch the playbook project for your site and initialize it
//The Antora pipeline is controlled by a playbook which is hosted in a playbook project. //The Antora pipeline is controlled by a playbook which is hosted in a playbook project.
......
...@@ -163,7 +163,7 @@ function readComponentDesc (files) { ...@@ -163,7 +163,7 @@ function readComponentDesc (files) {
async function loadGitFiles (repository, branch, repo) { async function loadGitFiles (repository, branch, repo) {
const tree = await getGitTree(repository, branch, repo.startPath) const tree = await getGitTree(repository, branch, repo.startPath)
const entries = await getGitEntries(tree) const entries = await getGitEntries(tree)
const vfiles = entries.map(async (entry) => { const files = entries.map(async (entry) => {
const blob = await entry.getBlob() const blob = await entry.getBlob()
const contents = blob.content() const contents = blob.content()
const stat = new fs.Stats({}) const stat = new fs.Stats({})
...@@ -171,7 +171,7 @@ async function loadGitFiles (repository, branch, repo) { ...@@ -171,7 +171,7 @@ async function loadGitFiles (repository, branch, repo) {
stat.size = contents.length stat.size = contents.length
return new File({ path: entry.path(), contents, stat }) return new File({ path: entry.path(), contents, stat })
}) })
return Promise.all(vfiles) return Promise.all(files)
} }
async function getGitTree (repository, branch, startPath) { async function getGitTree (repository, branch, startPath) {
...@@ -196,12 +196,11 @@ function getGitEntries (tree, onEntry) { ...@@ -196,12 +196,11 @@ function getGitEntries (tree, onEntry) {
async function loadLocalFiles (repo) { async function loadLocalFiles (repo) {
const basePath = path.join(repo.url, repo.startPath || '.') const basePath = path.join(repo.url, repo.startPath || '.')
const vfileStream = vfs.src('**/*.*', { return streamToArray(vfs.src('**/*.*', {
base: basePath, base: basePath,
cwd: basePath, cwd: basePath,
dot: false, dot: false,
}) }))
return streamToArray(vfileStream)
} }
function assignFileProperties (file, url, branch, startPath = '/') { function assignFileProperties (file, url, branch, startPath = '/') {
......
...@@ -130,7 +130,7 @@ Each virtual file object should include the following properties: ...@@ -130,7 +130,7 @@ Each virtual file object should include the following properties:
* `component` * `component`
* `version` * `version`
* `module` * `module`
* `family` (attachment, example, fragment, image, navigation, or page) * `family` (attachment, example, partial, image, navigation, or page)
* `topics` * `topics`
* `moduleRootPath` * `moduleRootPath`
* `basename` * `basename`
......
...@@ -80,7 +80,7 @@ function partitionSrc (file, pathSegments, nav) { ...@@ -80,7 +80,7 @@ function partitionSrc (file, pathSegments, nav) {
if (pathSegments[2] === 'documents') { if (pathSegments[2] === 'documents') {
if (pathSegments[3] === '_partials') { if (pathSegments[3] === '_partials') {
// QUESTION should this be partial-page instead? // QUESTION should this be partial-page instead?
file.src.family = 'fragment' file.src.family = 'partial'
// start from 4 (after /modules/foo/documents/_partials) end at -1 (before filename.ext) // start from 4 (after /modules/foo/documents/_partials) end at -1 (before filename.ext)
file.src.subpath = pathSegments.slice(4, -1).join('/') file.src.subpath = pathSegments.slice(4, -1).join('/')
} else if (file.src.mediaType === 'text/asciidoc' && file.src.basename !== '_attributes.adoc') { } else if (file.src.mediaType === 'text/asciidoc' && file.src.basename !== '_attributes.adoc') {
......
...@@ -71,7 +71,7 @@ describe('classifyContent()', () => { ...@@ -71,7 +71,7 @@ describe('classifyContent()', () => {
component: 'the-component', component: 'the-component',
version: 'v1.2.3', version: 'v1.2.3',
module: 'ROOT', module: 'ROOT',
family: 'fragment', family: 'partial',
subpath: '', subpath: '',
moduleRootPath: '../..', moduleRootPath: '../..',
}) })
......
...@@ -105,7 +105,7 @@ If the target page cannot be resolved, a warning should be emitted. ...@@ -105,7 +105,7 @@ If the target page cannot be resolved, a warning should be emitted.
=== Include processor === Include processor
The target of all include directives should be resolved from the content catalog. The target of all include directives should be resolved from the content catalog.
An include target must point to a file local to the current module, either in the `fragment` family or the `example` family. An include target must point to a file local to the current module, either in the `partial` family or the `example` family.
For example: For example:
include::{partialsdir}/partial.adoc[] include::{partialsdir}/partial.adoc[]
......
...@@ -4,10 +4,10 @@ const path = require('path') ...@@ -4,10 +4,10 @@ const path = require('path')
const convertAsciiDocString = require('./asciidoctor') const convertAsciiDocString = require('./asciidoctor')
const samplesdir = '$samples$' const examplesdir = '$examples$'
const fragmentsdir = '$fragments$' const partialsdir = '$partials$'
module.exports = async function convertDocument (file, playbookAsciidoctor, vfileCatalog) { module.exports = async function convertDocument (file, customAttributes, catalog) {
const options = { const options = {
safe: 'safe', safe: 'safe',
attributes: Object.assign( attributes: Object.assign(
...@@ -19,7 +19,7 @@ module.exports = async function convertDocument (file, playbookAsciidoctor, vfil ...@@ -19,7 +19,7 @@ module.exports = async function convertDocument (file, playbookAsciidoctor, vfil
idseparator: '-', idseparator: '-',
icons: 'font', icons: 'font',
}, },
playbookAsciidoctor, customAttributes,
{ {
// fixed attributes // fixed attributes
docname: file.src.stem, docname: file.src.stem,
...@@ -28,8 +28,8 @@ module.exports = async function convertDocument (file, playbookAsciidoctor, vfil ...@@ -28,8 +28,8 @@ module.exports = async function convertDocument (file, playbookAsciidoctor, vfil
'env-site': '', 'env-site': '',
imagesdir: file.out.moduleRootPath + '/_images', imagesdir: file.out.moduleRootPath + '/_images',
attachmentsdir: file.out.moduleRootPath + '/_attachments', attachmentsdir: file.out.moduleRootPath + '/_attachments',
samplesdir, examplesdir,
fragmentsdir, partialsdir,
} }
), ),
} }
...@@ -37,8 +37,8 @@ module.exports = async function convertDocument (file, playbookAsciidoctor, vfil ...@@ -37,8 +37,8 @@ module.exports = async function convertDocument (file, playbookAsciidoctor, vfil
const { attributes, htmlContents } = convertAsciiDocString( const { attributes, htmlContents } = convertAsciiDocString(
file.contents.toString(), file.contents.toString(),
options, options,
(doc, target) => readInclude(file, vfileCatalog, target), (doc, target) => readInclude(file, catalog, target),
(refId, text) => transformXref(file, refId, text, vfileCatalog) (refId, text) => transformXref(file, refId, text, catalog)
) )
file.contents = htmlContents file.contents = htmlContents
...@@ -47,7 +47,7 @@ module.exports = async function convertDocument (file, playbookAsciidoctor, vfil ...@@ -47,7 +47,7 @@ module.exports = async function convertDocument (file, playbookAsciidoctor, vfil
return Promise.resolve() return Promise.resolve()
} }
function readInclude (file, vfileCatalog, target) { function readInclude (file, catalog, target) {
const [targetFamily, ...targetPath] = target.split('/').filter((a) => a !== '') const [targetFamily, ...targetPath] = target.split('/').filter((a) => a !== '')
const findOptions = { const findOptions = {
...@@ -60,17 +60,17 @@ function readInclude (file, vfileCatalog, target) { ...@@ -60,17 +60,17 @@ function readInclude (file, vfileCatalog, target) {
const include = { file: target, path: file.src.basename } const include = { file: target, path: file.src.basename }
if (targetFamily === samplesdir) { if (targetFamily === examplesdir) {
findOptions.family = 'sample' findOptions.family = 'example'
} else if (targetFamily === fragmentsdir) { } else if (targetFamily === partialsdir) {
findOptions.family = 'fragment' findOptions.family = 'partial'
} else { } else {
// TODO log "Bad include" // TODO log "Bad include"
include.contents = `+include::${target}[]+` include.contents = `+include::${target}[]+`
return include return include
} }
const includeFile = vfileCatalog.getById(findOptions) const includeFile = catalog.getById(findOptions)
if (includeFile == null) { if (includeFile == null) {
// TODO log "Unknown include" // TODO log "Unknown include"
include.contents = `+include::${target}[]+` include.contents = `+include::${target}[]+`
...@@ -81,7 +81,7 @@ function readInclude (file, vfileCatalog, target) { ...@@ -81,7 +81,7 @@ function readInclude (file, vfileCatalog, target) {
return include return include
} }
function transformXref (file, xref, title, vfileCatalog) { function transformXref (file, xref, title, catalog) {
const xrefSrc = getSourceFromXref(xref) const xrefSrc = getSourceFromXref(xref)
if (xrefSrc == null) { if (xrefSrc == null) {
...@@ -89,7 +89,7 @@ function transformXref (file, xref, title, vfileCatalog) { ...@@ -89,7 +89,7 @@ function transformXref (file, xref, title, vfileCatalog) {
return `<a href="#">${xref}</a>` return `<a href="#">${xref}</a>`
} }
const xrefFile = vfileCatalog.getById({ const xrefFile = catalog.getById({
component: xrefSrc.component || file.src.component, component: xrefSrc.component || file.src.component,
version: xrefSrc.version || file.src.version, version: xrefSrc.version || file.src.version,
module: xrefSrc.module || file.src.module, module: xrefSrc.module || file.src.module,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment