Skip to main content

Extension for Foliant documentation generator to build subset of Foliant projects.

Project description

Subset

This CLI extension adds the command subset that generates a config file for a subset (i.e. a detached part) of the Foliant project. The command uses:

  • the common (i.e. default, single) config file for the whole Foliant project;
  • the part of config that is individual for each subset. The Foliant project may include multiple subsets that are defined by their own partial config files.

The command subset takes a path to the subset directory as a mandatory command line parameter.

The command subset:

  • reads the partial config of the subset;
  • optionally rewrites the paths of Markdown files that specified there in the chapters section;
  • merges the result with the default config of the whole Foliant project config;
  • finally, writes a new config file that allows to build a certain subset of the Foliant project with the make command.

Installation

To install the extension, use the command:

$ pip install foliantcontrib.subset

Usage

To get the list of all necessary parameters and available options, run foliant subset --help:

$ foliant subset --help
usage: foliant subset [-h] [-p PROJECT_DIR_PATH] [-c CONFIG] [-n] [-d] SUBPATH

Generate the config file to build the project subset from SUBPATH.

positional arguments:
  SUBPATH               Path to the subset of the Foliant project

optional arguments:
  -h, --help            show this help message and exit
  -p PROJECT_DIR, --path PROJECT_DIR
                        Path to the Foliant project
  -c CONFIG, --config CONFIG
                        Name of config file of the Foliant project, default 'foliant.yml'
  -n, --norewrite       Do not rewrite the paths of Markdown files in the subset partial config
  -d, --debug           Log all events during build. If not set, only warnings and errors are logged

In most cases it’s enough to use the default values of optional parameters. You need to specify only the SUBPATH—the directory that should be located inside the Foliant project source directory.

Suppose you use the default settings. Then you have to prepare:

  • the common (default) config file foliant.yml in the Foliant project root directory;
  • partial config files for each subset. They also must be named foliant.yml, and they must be located in the directories of the subsets.

Your Foliant project tree may look so:

$ tree
.
├── foliant.yml
└── src
    ├── group_1
       ├── product_1
          └── feature_1
              ├── foliant.yml
              └── index.md
       └── product_2
           ├── foliant.yml
           └── main.md
    └── group_2
        ├── foliant.yml
        └── intro.md

The command foliant subset group_1/product_1/feautre_1 will merge the files ./src/group_1/product_1/feautre_1/foliant.yml and ./foliant.yml, and write the result into the file ./foliant.yml.subset.

After that you may use the command like the following to build your Foliant project:

$ foliant make pdf --config foliant.yml.subset

Let’s look at some examples.

The content of the common (default) file ./foliant.yml:

title: &title Default Title

subtitle: &subtitle Default Subtitle

version: &version 0.0

backend_config:
    pandoc:
        template: !path /somewhere/template.tex
        reference_docx: !path /somewhere/reference.docx
        vars:
            title: *title
            version: *version
            subtitle: *subtitle
            year: 2018
        params:
            pdf_engine: xelatex

The content of the partial config file ./src/group_1/product_1/feautre_1/foliant.yml:

title: &title Group 1, Product 1, Feature 1

subtitle: &subtitle Technical Specification

version: &version 1.0

chapters:
    - index.md

backend_config:
    pandoc:
        vars:
            year: 2019

The content of newly generated file ./foliant.yml.subset:

title: &title Group 1, Product 1, Feature 1
subtitle: &subtitle Technical Specification
version: &version 1.0
backend_config:
    pandoc:
        template: !path /somewhere/template.tex
        reference_docx: !path /somewhere/reference.docx
        vars:
            title: *title
            version: *version
            subtitle: *subtitle
            year: 2019
        params:
            pdf_engine: xelatex
chapters:
- b2b/order_1/feature_1/index.md

If the option --no-rewrite is not set, the paths of Markdown files that are specified in the chapters section of the file ./src/group_1/product_1/feautre_1/foliant.yml, will be rewritten as if these paths were relative to the directory ./src/group_1/product_1/feautre_1/.

Otherwise, the Subset CLI extension will not rewrite the paths of Markdown files as if they were relative to ./src/ directory.

Note that the Subset CLI Extension merges the data of the config files recursively, so any subkeys of default config may be overridden by the settings of partial config.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

foliantcontrib.subset-1.0.9.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

foliantcontrib.subset-1.0.9-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file foliantcontrib.subset-1.0.9.tar.gz.

File metadata

  • Download URL: foliantcontrib.subset-1.0.9.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.11.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

File hashes

Hashes for foliantcontrib.subset-1.0.9.tar.gz
Algorithm Hash digest
SHA256 f4ee4e4bb085ca4dacfb8d752d9a751aef782f714e9c339582c384b5e6d61559
MD5 04c5b9bf44c9038cdc9b1ee77ec072fd
BLAKE2b-256 e13803fa7c93bd32d955262f4caf6e017b34992263909c1a857a22d8e0f5dca8

See more details on using hashes here.

File details

Details for the file foliantcontrib.subset-1.0.9-py3-none-any.whl.

File metadata

  • Download URL: foliantcontrib.subset-1.0.9-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.11.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

File hashes

Hashes for foliantcontrib.subset-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 b2297f0085e13624c3f66d18f91a330d062d2be884a080176c8484e646d48f1e
MD5 3072c84684869c738f5f32eb887defa7
BLAKE2b-256 8d92e7f6f83a47f8d142df4e7aa92542e32ef4978bae3b7ba380e0efbb270117

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page