The documentation system tenet of embedding and blending states that external information should be embedded and seamlessly blended with the relevant document rather than forcing users to look up missing information on external systems. This tenet extends the tenet of composability by including all content typesârather than just documentsâas the potential components of a composite document. As such, it supports the same principles of shared responsibility and truth proximity.Â
While embedding is essentially a form of composition, the difference is that the composed content comes from external systems rather than the documentation system itself. Embedding is not necessarily meant to work like an automated form copy-pasting, and neither like an HTML IFRAME. This is why the tenet does not just use the word embedding; it is embedding and blending.
Blending means that the embedding mechanism should allow the flexible querying and extracting of components from the relevant external source in such a way that they appear as regular documentation elements, so that âall knowledge workersâauthors and usersâmodify and incorporate other knowledge products into their own information bases and knowledge productsâ. (Engelbart, 1995). We will illuminate this concept in a moment.
Given that embedding is a form of composition, we can also see the capability from two angles: Intra-document embedding and blending, and inter-document embedding and blending.
Similarly to intra-document composability, inter-document embedding and blending refers to the ability to embed external sources directly from a given document.
In this example, the document describes the notion of a Discount, for which it references an Excel file in which the discount types are maintained.Â
---
title: Discount
author : Sarah Jones
date: 2024-09-15
imports:
discounts: /common/discounts.xlsx
---
# Discount
A product may be associated with a type of discount which reduces the productâs price. It may be applied to both retail and business customers and it is always active during a defined timeframe.
# Discount Types
These are the types of discounts that we offer:
@discounts[sheet=discount_codes,hide_columns=C,D]
In the above example, the directive @discounts references the file discounts.xlsx specified as YAML metadata. The directive selects the sheet named discount_table, and hides columns C and D.
Implementing embedding and blending across documents is a rather common DocOps approach, rather than a fallback whenever we are unable to extend the primary or existing document formats to support embedding and blending directives. Typical inter-document embedding and blending use cases include:
The next example illustrates the case of appending the Discount Types heading to an existing document using shell scripting. The open source xlsx2csv and csv2md command line utilities are used to convert an Excel file to a comma separated value (CSV) text file, and a CSV text file to markdown, respectively.
#!/bin/bash
cp discount_raw.md final.md
echo -en "# Discount Types\n\n" >> final.md
echo -en "These are the types of discounts" >> final.md
echo -en "that we offer:\n\n" >> final.md
xlsx2csv -n discount_codes discounts.xlsx > discounts.csv
csv2md discounts.csv >> final.md
cat final.md
So far we have seen examples of embedding an external sourceâan Excel spreadsheet, but nothing about blending, other than mentioning that it is not necessarily supposed to work like an automated form of copy-pasting. To illustrate what we mean by blending, the below Markdown file illustrates the result of implementing either of the processing techniques seen earlier.
---
title: Discount
author : Sarah Jones
date: 2024-09-15
---
# Discount
A product may be associated with a type of discount which reduces the productâs price. It may be applied to both retail and business customers and it is always active during a defined timeframe.
# Discount Types
These are the types of discounts that we offer:
Type Description
â--- â----------
L1 A discount of up to 10%
L2 A discount of up to 20%
L3 A discount of up to 30%
What we see here is that rather than creating a screenshot of the Excel table, or creating an IFRAME-like component which displays an Excel widget, we have extracted the content from Excel and translated it to a regular markdown table. The benefit is that once this markdown document is rendered, the look and feel will be seamless and indistinguishable from a table created by hand.Â
For blending to be effective, it needs to be implemented in such a way that it can satisfy various use cases rather than converting the underlying data in one way only. For example, the directive @discounts[sheet=discount_codes,headings=[(2,A,B)]
could tell the markdown preprocessor to treat column A as a level 2 heading, and column B as the content for said heading. The next code snippet exemplifies the expected result.
# Discount Types
These are the types of discounts that we offer:
## L1
A discount up to 5%
## L2
A discount up to 15%
## L3
A discount up to 20%
To recap, embedding is effectively a form of compositionâexcept that it uses external sourcesâand blending is the ability to structure the embedded data using native document elements. Blending also supports the tenet of consistent layout.
The exact embedding capabilities will vary depending on the type of external source being embedded.
We consider âdataâ any source of tabular or structured information, be it in the form of static files (spreadsheets, CSV files, JSON files, etc.), proper database management systems (relational, NoSQL, etc.), but also systems that offer querying capabilities such as bug tracking and service management systems.
The general capabilities that we need for such systems are as follows:
Image processing is one of the most neglected aspects in current documentation systems. The capability of âdisplayingâ an image is often assumed to be about the inclusion of a file that is already saved in a format compatible with the final rendering format, such as a JPEG or PNG file in an HTML-based view. The problem is that images are rarely authored in such formats; manual âexportâ, conversion, or copy-paste steps are required before they can be used. This conflicts with the principle of truth proximity.
Broadly speaking, images are encoded using pixel or vector formats. Let us briefly talk about them.Â
Pixel image formats (also called ârasterâ) are authored in applications such as Adobe Photoshop or GIMP. In their original format, pixel images may contain multiple layers and use higher resolutions and color depths than appropriate for direct inclusion in web-based documents.
Vector image formats consist of a set of geometrical directives that allow drawing images in a resolution-independent manner. Printers use this kind of directives so that the result improves the greater the DPI (dots per inch) depth. Popular vector image editors include Adobe Freehand and Inkscape.Â
We also have diagram-oriented tools such as Microsoft Visio, LucidChart and Draw.io whereby images are meant to serve as blueprints: floor plans, business flows, and so on. These tools use proprietary vector-based formats but can also export files in pixel-based formats. Microsoft PowerPoint could be described as a hybrid tool given that it typically combines both pixel and vector-based elements.
It is also worth noting that there are a variety of engineering and business applications such as computer aided design (CAD) tools, for example, Sparxs EA, spreadsheets such as Google Sheets, and business intelligence applications like Microsoft PowerBI whose goal is not general âimage authoringâ but whose output is visual in nature.
As explained earlier, embedding an image produced by any external source should not require accessing the external system (e.g., Microsoft Visio) and manually exporting said image in a document-friendly format. The conversion from Visio to PNGâif that is the âfriendlyâ formatâis a DocOps problem, rather than an end-user one.Â
To honor the principle of truth proximity, embedding and blending an image should be done in such a way that either the original image is referenced directly without any manual âexportâ steps, or, alternatively, the conversion is performed automatically so that images in documentation-compatible formats (PNG, JPEG, SVG, etc.) are made available on a zero touch basis.
There will always be specific needs depending on the image-producing source systemâs peculiarities, but these are the general capabilities that apply to image embedding:
Video and audio are closely related in the sense that a video stream includes both motion pictures and an audio streamâoften encoded using the similar formats as stand-alone audio streams. Also, it is common to take a video stream and extract still pictures, and audio.
There are a number of complex automation workflows that may be applied to both video and audio which escape the scope of this book. However, some of the fundamental capabilities include:
When documenting âcodeâ we may be writing something as simple as a âgetting startedâ guide or as complex as a complete API reference manual. Each use case calls for a different approach. For example, for introductory material including the likes of tutorials, getting started guides, and so on, we might embed small code fragments from within a body of text, whereas for formal reference documentation, it may be preferable to maintain the narrative together with the code itself and generate the documentation using DocOps automation techniques.
Code is also not only used in the form of code listing but referenced within sentences and paragraphs in which there is a chance of typos and/or inaccuracyâe.g., referencing a function name that has been renamed or no longer exists.Â
Truth proximity is paramount in the particular case of code embedding and blending. The following is a list of the most common capabilities, each of which would apply depending on the nature of the documentation objective and the shape and nature of the associated code base.
**bold**
, or _italics_
âwhich would then be seamlessly blended with the document to maintain the relevant function/method documentation with the code itself© 2022-2024 Ernesto Garbarino | Contact me at ernesto@garba.org