2

Background

Looking to understand the definitive relationship between projects, products, environments, and components.

Minimum Working Example

Here's the directory structure showing the problem:

project
├── project/novel
│   ├── project/novel/component.tex
│   ├── project/novel/contents.tex
│   ├── project/novel/prd_para.tex
│   └── project/novel/product.tex
├── project/prj_para.tex
└── project/project.tex

./project/project.tex

\startproject project
  \environment prj_para

  \product product
\stopproject

./project/prj_para.tex

\startenvironment prj_para
  \define\bookname{Project Name}
\stopenvironment

./project/novel/prd_para.tex

% Does not override \bookname from prj_para.tex?
\startenvironment prd_para
  \define\bookname{Product Name}
\stopenvironment

./project/novel/component.tex

\startcomponent component
  \project project

  \bookname

  \input contents
\stopcomponent

./project/novel/contents.tex

Pride and Prejudice

Jane Austen

\section[title={chapter-1},reference={chapter-1}]

It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife.

./project/novel/product.tex

\startproduct
  \project project

  \environment prd_para

  \component component
\stopproduct

Building

The project is built from within the project directory:

context novel/product --path=novel 

Setup

The following setup is what I'd like to achieve:

Project Structure

Every product "inherits" its environment settings from a global project. Each product can override specific settings. For example, the project could define Arial as the base font for all products, but one product could redefine it as Helvetica.

Problem

Ideally, the setups in the project-level prj_para.tex (i.e., "project-wide" as per the project structure diagram) could be changed in the product-level prd_para.tex.

However, the value for \bookname is always Project Name, rather than Product Name. Here is how the output appears:

Example Output

Question

Using environments, projects, products, and components, how can setups in the project-wide environments be changed by the product-specific environments?

In short, how can "Product Name" be output instead?

References

Various documentation sources seem to contradict each other, for example startcomponent shows:

\startcomponent *
   \project projectname

While Project structure shows:

\startcomponent c_editorial
  \product prd_year2004-01 % but you can use it in other products anyway

Neither Magazine #1101, July 2011 nor Magazine #1101, September 2016 explicitly state how \startcomponent/\stopcomponent is codified in relation to either projects or products.

The mailing list has numerous questions with specific answers, but nothing broad in scope. A Python Script generates files and directories, but without understanding how those files and directories relate, it offers little insight.

The wiki states:

  • a project links one or more products to their environment
  • a product contains several components
  • an environment defines the common layout (etc.) of a project

In addition, there are numerous answers on TeX.SE, but few show a tree with all files and directories:

8
  • 2
    Repeating an earlier comment of mine: “projects are essentially collections of environments” Apr 19, 2020 at 1:38
  • The beginner's manual should meet most of your requirements. github.com/contextgarden/context-mirror/tree/beta/doc/context/… Apr 19, 2020 at 4:17
  • Oh, and just to clarify my previous comment: You don't “compile the entire project”. You always compile the individual products. I don't think compiling project files is even supported or implemented. Apr 19, 2020 at 4:19
  • FWIW, I always use only components and environments. To get a "collection of environments" I simply contain a main environment which calls other environments.
    – Aditya
    Apr 19, 2020 at 5:32
  • 1
    You're missing the name after \startproduct which results in the wrong output. I suggest to also use the \input in you component file and move either the content in this file or make the content itself in a component (components can be nested). Apr 19, 2020 at 19:44

1 Answer 1

0

The following works as expected using the given directory hierarchy:

% File: prj_para.tex
\startenvironment *
  \setuplayout[
    grid=yes,
  ]

  \define\bookname{Project Name}
\stopenvironment

% File: prd_para.tex
\startenvironment *
  \setuplayout[
    grid=no,
  ]

  \define\bookname{Product Name}
\stopenvironment

% File: component.tex
\startcomponent *
  \project project

  \bookname

  \component contents
\stopcomponent

% File: product.tex (note that * was missing)
\startproduct *
  \project project

  \environment prd_para

  \component component
\stopproduct

This produces:

Output, not grid-aligned

If we remove the \setuplayout from prd_para.tex, the output changes to grid-aligned typesetting:

Output, grid-aligned

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .