Skip to main content

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.

Metadata

Release files for foliantcontrib.subset 1.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for foliantcontrib.subset 1.0.9
File Size Uploaded
foliantcontrib.subset-1.0.9.tar.gz 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for foliantcontrib.subset 1.0.9
File Interpreter ABI Platform
foliantcontrib.subset-1.0.9-py3-none-any.whl Python 3 none any Details

Total release size: 11.5 kB

Release files / foliantcontrib.subset-1.0.9.tar.gz

Download URL foliantcontrib.subset-1.0.9.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f4ee4e4bb085ca4dacfb8d752d9a751aef782f714e9c339582c384b5e6d61559
BLAKE2b-256 checksum
How to use checksums
e13803fa7c93bd32d955262f4caf6e017b34992263909c1a857a22d8e0f5dca8
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / foliantcontrib.subset-1.0.9-py3-none-any.whl

Download URL foliantcontrib.subset-1.0.9-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2297f0085e13624c3f66d18f91a330d062d2be884a080176c8484e646d48f1e
BLAKE2b-256 checksum
How to use checksums
8d92e7f6f83a47f8d142df4e7aa92542e32ef4978bae3b7ba380e0efbb270117
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.0.9 This release

2 release files

1.0.8

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page