asciisourcerer 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.adoc +392 -0
- data/lib/asciisourcerer.rb +32 -0
- data/lib/sourcerer/asciidoc.rb +483 -0
- data/lib/sourcerer/builder.rb +155 -0
- data/lib/sourcerer/jekyll/bootstrapper.rb +78 -0
- data/lib/sourcerer/jekyll/liquid/file_system.rb +74 -0
- data/lib/sourcerer/jekyll/liquid/filters.rb +173 -0
- data/lib/sourcerer/jekyll/liquid/tags.rb +44 -0
- data/lib/sourcerer/jekyll/monkeypatches.rb +72 -0
- data/lib/sourcerer/jekyll.rb +31 -0
- data/lib/sourcerer/mark_down_grade.rb +693 -0
- data/lib/sourcerer/plaintext_converter.rb +73 -0
- data/lib/sourcerer/rendering.rb +186 -0
- data/lib/sourcerer/templating.rb +201 -0
- data/lib/sourcerer/version.rb +5 -0
- data/lib/sourcerer/yaml.rb +146 -0
- data/lib/sourcerer.rb +102 -0
- metadata +163 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 95a070a99788cf778b389f7e78810695d8461c31ba7480fc0c4d877a110a1b9a
|
|
4
|
+
data.tar.gz: a993ba2270a205d38b39de83be2a8d9671d9b1a1224213d4935244e481638c06
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: f16ebd7d4f868d7864c8c17e923b817f6d54ec8b155cf4b3bdcb90ec58f1c8f6d1570610b9086008177d995619ed551931117d52f71534af7306a68ac25a4383
|
|
7
|
+
data.tar.gz: 575747ad2af8032b928126e9294e26bb18268c4c9097cae2fd8757909450a0826079f57bbb1b96711b53db3001dfed02ddc199d48a175ee57ca467ae68bf678f
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DocOps Lab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.adoc
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
:page-layout: default
|
|
2
|
+
:page-permalink: /docs
|
|
3
|
+
:page-nav_order: 1
|
|
4
|
+
= AsciiSourcerer
|
|
5
|
+
// tag::ai-prompt[]
|
|
6
|
+
// Collects AsciiDoc content for presenting to a generative AI prompt
|
|
7
|
+
// Other AI-only prompt matter could go here
|
|
8
|
+
// tag::globals[]
|
|
9
|
+
:docopslab_git_www: https://github.com/DocOps
|
|
10
|
+
:this_prod_slug: asciisourcerer
|
|
11
|
+
:asciisourcerer_prod_repo: {docopslab_git_www}/{this_prod_slug}
|
|
12
|
+
:asciisourcerer_prod_repo_files_path: {asciisourcerer_prod_repo}/blob/main
|
|
13
|
+
:this_prod_repo: {asciisourcerer_prod_repo}
|
|
14
|
+
:this_prod_vrsn_major: 0
|
|
15
|
+
:this_prod_vrsn_minor: 1
|
|
16
|
+
:this_prod_vrsn_major-minor: {this_prod_vrsn_major}.{this_prod_vrsn_minor}
|
|
17
|
+
:this_prod_vrsn_patch: 0
|
|
18
|
+
:this_prod_vrsn: {this_prod_vrsn_major-minor}.{this_prod_vrsn_patch}
|
|
19
|
+
:next_prod_vrsn: 0.2.0
|
|
20
|
+
// Default configuration values - single source of truth for config-def.yml
|
|
21
|
+
:this_prod_repo_branch: {this_prod_repo}/tree/release/{this_prod_vrsn_major-minor}
|
|
22
|
+
ifdef::env-github[]
|
|
23
|
+
:docs_extn: .adoc
|
|
24
|
+
:asciisourcerer_www: https://asciisourcerer.docopslab.org
|
|
25
|
+
:asciisourcerer_docs_www: {asciisourcerer_www}/docs
|
|
26
|
+
:default-config_www: {asciisourcerer_docs_www}/sample-config.html
|
|
27
|
+
:this_prod_docs_www: {asciisourcerer_docs_www}
|
|
28
|
+
endif::[]
|
|
29
|
+
ifndef::env-github[]
|
|
30
|
+
:docs_extn:
|
|
31
|
+
endif::[]
|
|
32
|
+
// end::globals[]
|
|
33
|
+
:toc: macro
|
|
34
|
+
:toclevels: 3
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
AsciiSourcerer is a Ruby library for radical single-sourcing of documentation and product data, primarily from AsciiDoc, YAML, and Liquid templating operations.
|
|
38
|
+
|
|
39
|
+
[[intro]]
|
|
40
|
+
== Introduction
|
|
41
|
+
|
|
42
|
+
AsciiSourcerer is an API-first Ruby gem designed to sit upstream of DocOps Lab generators and tooling, letting dependent code extract, reshape, and render data and content consistently across build-time and runtime workflows.
|
|
43
|
+
|
|
44
|
+
Its end user base is expected to be Ruby developers; for user-friendlier applications with practical applications, see <<integrations>>.
|
|
45
|
+
|
|
46
|
+
[NOTE]
|
|
47
|
+
The core module is canonically called `Sourcerer` and is usually referred to as such in documentation.
|
|
48
|
+
The module `AsciiSourcerer` serves as an alias to `Sourcerer` in case of namespace conflicts.
|
|
49
|
+
|
|
50
|
+
[[capabilities]]
|
|
51
|
+
=== Capabilities
|
|
52
|
+
|
|
53
|
+
The API focuses on a small set of robust primitives that downstream tools can compose.
|
|
54
|
+
|
|
55
|
+
AsciiDoc extraction::
|
|
56
|
+
Load attributes, transclude tagged snippets, extract tagged regions, and convert documents from AsciiDoc source files.
|
|
57
|
+
|
|
58
|
+
Tag-aware YAML loading::
|
|
59
|
+
Load YAML files while preserving custom tags and optionally resolving embedded AsciiDoc attributes and Liquid/ERB template syntax.
|
|
60
|
+
|
|
61
|
+
Templating and rendering::
|
|
62
|
+
Render Liquid or ERB templates against YAML data or AsciiDoc attributes.
|
|
63
|
+
|
|
64
|
+
Liquid runtime integration::
|
|
65
|
+
Initialize a Jekyll-routed Liquid runtime with DocOps Lab filters and tags, so Jekyll-compatible templates behave predictably.
|
|
66
|
+
|
|
67
|
+
Build-time generation::
|
|
68
|
+
Generate prebuild artifacts (attributes, snippets, regions) for downstream builds and runtime access.
|
|
69
|
+
|
|
70
|
+
AsciiDoc-to-manpage conversion::
|
|
71
|
+
Build manpages for apps from the docs.
|
|
72
|
+
|
|
73
|
+
AsciiDoc-to-Markdown conversion::
|
|
74
|
+
Convert AsciiDoc documents to Markdown for agentic consumption, with a focus on preserving semantic structure and document frontmatter.
|
|
75
|
+
|
|
76
|
+
All of these operations are meant to be available even before resources like SchemaGraphy and LiquiDoc are loaded.
|
|
77
|
+
Most are best invoked via a <<integrations,downstream API or utility>>, where robust services for _input_ (file read), _output_ (file write), _configuration_, _scripting_, and contextual _enrichment_ may be available via CLI or API.
|
|
78
|
+
|
|
79
|
+
[[core-concepts]]
|
|
80
|
+
=== Core Concepts
|
|
81
|
+
|
|
82
|
+
Sourcerer workflows involve some terms of art, which we define here to keep the process consistent across different syntaxes.
|
|
83
|
+
|
|
84
|
+
single-sourcing::
|
|
85
|
+
Treat AsciiDoc and YAML as authoritative sources so the same data can power documentation, configuration, and build artifacts.
|
|
86
|
+
|
|
87
|
+
AsciiDoc attributes::
|
|
88
|
+
AsciiDoc attributes are key-value pairs defined in AsciiDoc documents that can be loaded as data and used for templating, configuration, and metadata.
|
|
89
|
+
|
|
90
|
+
tagged regions::
|
|
91
|
+
Sections of source files demarcated by `tag::` and `end::` markers, which can be extracted as content snippets for reuse in documentation or other outputs.
|
|
92
|
+
|
|
93
|
+
YAML tags::
|
|
94
|
+
Custom YAML tags (ex: `!liquid`, `!attribute`) that provide special processing instructions during YAML loading.
|
|
95
|
+
Tags are a supported element of the YAML specification but leave handling up to the application, soAsciiSourcerer provides a mechanism for preserving and processing them.
|
|
96
|
+
|
|
97
|
+
templating engines::
|
|
98
|
+
Liquid and ERB are supported templating engines.
|
|
99
|
+
Sourcerer uses standard Ruby ERB, but for Liquid, the engine is modified by bootstrapping Jekyll's Liquid runtime and enhancing it with Liquid extensions like custom tags and filters.
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
[[usage]]
|
|
103
|
+
== Usage
|
|
104
|
+
|
|
105
|
+
Sourcerer is a library, so you call it from Ruby code rather than a CLI.
|
|
106
|
+
The most common workflows are summarized below.
|
|
107
|
+
|
|
108
|
+
Basic render flow::
|
|
109
|
+
Load YAML data, optionally enrich it with AsciiDoc attributes, render a template, and write output to a file.
|
|
110
|
+
|
|
111
|
+
Prebuild flow::
|
|
112
|
+
Extract attributes and tagged content from AsciiDoc into artifacts that are loaded at runtime.
|
|
113
|
+
|
|
114
|
+
Converter flow::
|
|
115
|
+
Use a custom converter (callable or constant name) to produce specialized output without embedding converter logic into the core rendering pipeline.
|
|
116
|
+
|
|
117
|
+
[[quickstart]]
|
|
118
|
+
=== Quickstart
|
|
119
|
+
|
|
120
|
+
Add `asciisourcerer` to your application using Bundler.
|
|
121
|
+
|
|
122
|
+
.Gemfile addition
|
|
123
|
+
[source,ruby,subs=+attributes]
|
|
124
|
+
----
|
|
125
|
+
gem 'asciisourcerer', '~> {this_prod_vrsn_major-minor}'
|
|
126
|
+
----
|
|
127
|
+
|
|
128
|
+
Then require and use it in your Ruby code.
|
|
129
|
+
|
|
130
|
+
[NOTE]
|
|
131
|
+
Applications can use either the `Sourcerer` (canonical) or `AsciiSourcerer` (permanent alias) module namespace.
|
|
132
|
+
The full `AsciiSourcerer` namespace is recommended if your application also uses the unaffiliated link:https://rubygems.org/search?query=sourcerer[`sourcerer`] gem, which does not appear to be currently maintained.
|
|
133
|
+
|
|
134
|
+
Primary API namespaces:
|
|
135
|
+
|
|
136
|
+
* `Sourcerer::AsciiDoc` for attribute loading, includes, tagged-region extraction, and document generation (manpage, HTML, Markdown).
|
|
137
|
+
* `Sourcerer::Yaml` for YAML loading with tag preservation and optional attribute resolution.
|
|
138
|
+
* `Sourcerer::Yaml::TagUtils` for tag helper methods (`detag`, `tag_of`, `tag?`).
|
|
139
|
+
* `Sourcerer::Rendering` for template rendering and output orchestration.
|
|
140
|
+
|
|
141
|
+
The top-level `Sourcerer.*` methods remain as compatibility delegators.
|
|
142
|
+
This layer is actually *deprecated* and will be removed in AsciiSourcerer 1.0.
|
|
143
|
+
|
|
144
|
+
.Example: Render a template with YAML data
|
|
145
|
+
[source,ruby]
|
|
146
|
+
----
|
|
147
|
+
require 'asciisourcerer'
|
|
148
|
+
|
|
149
|
+
Sourcerer::Rendering.render_template(
|
|
150
|
+
'template.liquid',
|
|
151
|
+
'data.yml',
|
|
152
|
+
'output.md',
|
|
153
|
+
data_object: 'data',
|
|
154
|
+
engine: 'liquid'
|
|
155
|
+
)
|
|
156
|
+
----
|
|
157
|
+
|
|
158
|
+
.Example: Generate semantic HTML5 from AsciiDoc
|
|
159
|
+
[source,ruby]
|
|
160
|
+
----
|
|
161
|
+
require 'asciisourcerer'
|
|
162
|
+
|
|
163
|
+
Sourcerer::AsciiDoc.generate_html(
|
|
164
|
+
'README.adoc',
|
|
165
|
+
'build/docs/readme.html',
|
|
166
|
+
backend: 'asciidoctor-html5s'
|
|
167
|
+
)
|
|
168
|
+
----
|
|
169
|
+
|
|
170
|
+
If `asciidoctor-html5s` is unavailable at runtime, Sourcerer falls back to the standard `html5` backend.
|
|
171
|
+
|
|
172
|
+
[[markdown-grade]]
|
|
173
|
+
=== MarkDownGrade (AsciiDoc -> Markdown)
|
|
174
|
+
|
|
175
|
+
`Sourcerer::MarkDownGrade` handles HTML-to-Markdown adaptation.
|
|
176
|
+
For end-to-end AsciiDoc conversion, use `Sourcerer::AsciiDoc.mark_down_grade`, which orchestrates AsciiDoc rendering and MarkDownGrade conversion.
|
|
177
|
+
|
|
178
|
+
Core behavior defaults::
|
|
179
|
+
* Preserve section heading anchors.
|
|
180
|
+
* Preserve semantic definition lists (`<dl>`, `<dt>`, `<dd>`).
|
|
181
|
+
* Preserve frontmatter when enabled.
|
|
182
|
+
* Support semantic backend requests with fallback (`asciidoctor-html5s` -> `html5s` or `html5`).
|
|
183
|
+
|
|
184
|
+
.Example: Convert AsciiDoc file to Markdown with frontmatter
|
|
185
|
+
[source,ruby]
|
|
186
|
+
----
|
|
187
|
+
require 'asciisourcerer'
|
|
188
|
+
|
|
189
|
+
result = Sourcerer::AsciiDoc.mark_down_grade(
|
|
190
|
+
'specs/tests/fixtures/frontmatter-sample.adoc',
|
|
191
|
+
'build/docs/frontmatter-sample.md',
|
|
192
|
+
html_output_path: 'build/docs/frontmatter-sample.html',
|
|
193
|
+
backend: 'asciidoctor-html5s',
|
|
194
|
+
include_frontmatter: true,
|
|
195
|
+
markdown_options: { github_flavored: true }
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
puts(result[:used_backend])
|
|
199
|
+
puts(result[:frontmatter].keys)
|
|
200
|
+
----
|
|
201
|
+
|
|
202
|
+
.Example: Convert HTML fragment to Markdown directly
|
|
203
|
+
[source,ruby]
|
|
204
|
+
----
|
|
205
|
+
require 'asciisourcerer'
|
|
206
|
+
|
|
207
|
+
html = <<~HTML
|
|
208
|
+
<h2 id="_sample">Sample</h2>
|
|
209
|
+
<p>Paragraph.</p>
|
|
210
|
+
HTML
|
|
211
|
+
|
|
212
|
+
markdown = Sourcerer::MarkDownGrade.convert_html(
|
|
213
|
+
html,
|
|
214
|
+
github_flavored: true
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
puts(markdown)
|
|
218
|
+
----
|
|
219
|
+
|
|
220
|
+
[[markdown-grade-migration]]
|
|
221
|
+
=== Migration Mini-Guide (DocOps Lab)
|
|
222
|
+
|
|
223
|
+
For consumers currently using `DocOps/lab/scripts/mark_down_grade.rb`, migrate to Sourcerer in two steps.
|
|
224
|
+
|
|
225
|
+
Step 1: Switch call sites to `asciisourcerer` API::
|
|
226
|
+
* Replace local script requires with `require 'asciisourcerer'`.
|
|
227
|
+
* Use `Sourcerer::AsciiDoc.mark_down_grade` for `.adoc -> .md` workflows.
|
|
228
|
+
* Use `Sourcerer::MarkDownGrade.convert_html` only when input is already HTML.
|
|
229
|
+
|
|
230
|
+
Step 2: Verify parity, then remove duplicate script::
|
|
231
|
+
* Compare representative outputs from Lab fixture inputs.
|
|
232
|
+
* Validate anchor, frontmatter, and semantic-block behavior for your workflow.
|
|
233
|
+
* Remove `lab/scripts/mark_down_grade.rb` after parity is confirmed.
|
|
234
|
+
|
|
235
|
+
Recommended follow-through::
|
|
236
|
+
* Redirect or retire `lab/scripts/README-mark_down_grade.adoc` so AsciiSourcerer remains source-of-truth.
|
|
237
|
+
|
|
238
|
+
[[templating-and-liquid-runtime]]
|
|
239
|
+
=== Templating and Liquid Runtime
|
|
240
|
+
|
|
241
|
+
Sourcerer supports Liquid and ERB, but its Liquid support is intentionally aligned with Jekyll’s runtime.
|
|
242
|
+
This keeps template behavior consistent with Jekyll projects while allowing DocOps Lab to register filters and tags.
|
|
243
|
+
|
|
244
|
+
If you are building a Jekyll-compatible templating pipeline, prefer Liquid.
|
|
245
|
+
If you want a low-friction Ruby template for internal tooling, ERB is available.
|
|
246
|
+
|
|
247
|
+
[[pipelines]]
|
|
248
|
+
=== Prebuild and Rendering Pipelines
|
|
249
|
+
|
|
250
|
+
Sourcerer’s rendering pipeline is optimized for build tooling and prebuild steps.
|
|
251
|
+
A typical prebuild might load attributes from `README.adoc`, extract tagged snippets into `build/snippets/`, and render YAML plus Liquid templates into `build/docs/`.
|
|
252
|
+
|
|
253
|
+
The API is intentionally small.
|
|
254
|
+
Sourcerer focuses on producing artifacts, not managing a broader build lifecycle.
|
|
255
|
+
|
|
256
|
+
Typical render entry shape::
|
|
257
|
+
Use `Sourcerer::Rendering.render_outputs` with an array of hashes.
|
|
258
|
+
Each hash can describe template rendering or converter-driven output:
|
|
259
|
+
|
|
260
|
+
* Template entry keys: `:template`, `:data`, `:out`, optional `:key`, `:attrs`, `:engine`
|
|
261
|
+
* Converter entry keys: `:converter`, `:data`, `:out`, plus converter-specific options
|
|
262
|
+
|
|
263
|
+
.Example: Mixed render pipeline
|
|
264
|
+
[source,ruby]
|
|
265
|
+
----
|
|
266
|
+
Sourcerer::Rendering.render_outputs([
|
|
267
|
+
{
|
|
268
|
+
template: 'templates/release-notes.liquid',
|
|
269
|
+
data: 'data/release.yml',
|
|
270
|
+
out: 'build/docs/release-notes.md',
|
|
271
|
+
key: 'release',
|
|
272
|
+
attrs: 'README.adoc',
|
|
273
|
+
engine: 'liquid'
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
converter: 'MyProject::JsonRenderer',
|
|
277
|
+
data: 'data/release.yml',
|
|
278
|
+
out: 'build/api/release.json'
|
|
279
|
+
}
|
|
280
|
+
])
|
|
281
|
+
----
|
|
282
|
+
|
|
283
|
+
Downstream filter responsibility::
|
|
284
|
+
Sourcerer ships generic Liquid utility filters only.
|
|
285
|
+
Schema-aware filters (including SGYML-specific classification filters) should be provided by downstream tooling such as SchemaGraphy and/or ReleaseHx.
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
[[integrations]]
|
|
289
|
+
== Integrations (Implemented and Planned)
|
|
290
|
+
|
|
291
|
+
These notes describe how AsciiSourcerer relates to existing and future downstream tools.
|
|
292
|
+
For most users, these tools are the recommended way to access AsciiSourcerer’s capabilities, since they provide a richer context for configuration, input/output management, and workflow orchestration.
|
|
293
|
+
|
|
294
|
+
SchemaGraphy::
|
|
295
|
+
SchemaGraphy's API is the schema-aware layer in the DocOps Lab ecosystem.
|
|
296
|
+
Sourcerer provides it with primitives such as YAML loading, templating, and Liquid runtime setup, while SchemaGraphy handles schema validation and templated-field interpretation.
|
|
297
|
+
SchemaGraphy depends on AsciiSourcerer for these primitives, not the other way around.
|
|
298
|
+
|
|
299
|
+
https://github.com/DocOps/releasehx[ReleaseHx]::
|
|
300
|
+
The ReleaseHx API and `rhx` CLI uses Sourcerer for generating source files during a prebuild stage, and at runtime for YAML ingest and template rendering.
|
|
301
|
+
|
|
302
|
+
LiquiDoc::
|
|
303
|
+
Secondary to SchemaGraphy, the scriptable template-rendering build utility LiquiDoc will use SchemaGraphy and AsciiSourcerer at runtime.
|
|
304
|
+
|
|
305
|
+
Jekyll Extensions::
|
|
306
|
+
DocOps Labs maintains plugins, themes, and even a utility for generating technical documentation with the Jekyll static-site generator.
|
|
307
|
+
All the benefits of extended YAML ingest and Liquid processing are available via these extensions, along with and usually through SchemaGraphy.
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
[[development]]
|
|
311
|
+
== Development
|
|
312
|
+
|
|
313
|
+
This section is for contributors working on AsciiSourcerer itself.
|
|
314
|
+
|
|
315
|
+
[[scope]]
|
|
316
|
+
=== Scope and Extensibility
|
|
317
|
+
|
|
318
|
+
Sourcerer is a primitive, upstream dependency and should remain a small, stable base layer.
|
|
319
|
+
It should not become a catch-all framework for schema processing, validation, or domain-specific logic.
|
|
320
|
+
|
|
321
|
+
Scope conclusions::
|
|
322
|
+
Keep AsciiSourcerer focused on core behaviors needed by downstream tools.
|
|
323
|
+
These include funky AsciiDoc processing (attribute extraction, alternate outputs), enhanced YAML loading (tag handling, template integration), and Jekyll/Liquid runtime support.
|
|
324
|
+
|
|
325
|
+
Avoid a formal plugin system in the near term::
|
|
326
|
+
Add capabilities directly when needed, but keep changes narrowly scoped and well-documented.
|
|
327
|
+
|
|
328
|
+
Schema-aware behavior belongs in SchemaGraphy::
|
|
329
|
+
SGYML, JSON Schema validation, and templated-field interpretation should "`wait`" for SchemaGraphy.
|
|
330
|
+
|
|
331
|
+
Prefer dependency injection over hard coupling::
|
|
332
|
+
Use callables or config hashes for advanced behaviors that must be orchestrated by downstream tools.
|
|
333
|
+
|
|
334
|
+
The AsciiSourcerer gem is not directly released in a "`Dockerized`" edition since it really is intended only to supply processing to Ruby tools.
|
|
335
|
+
Most user-facing benefits of the processing done here is better accessed via downstream tools.
|
|
336
|
+
|
|
337
|
+
[[docopslab-dev]]
|
|
338
|
+
=== DocOps Lab Devtool (`docopslab-dev`)
|
|
339
|
+
|
|
340
|
+
Special developer Rake tasks and libraries are available via the `docopslab-dev` gem.
|
|
341
|
+
|
|
342
|
+
.List tasks from `docopslab-dev`
|
|
343
|
+
[.prompt]
|
|
344
|
+
bundle exec rake --tasks | grep labdev:
|
|
345
|
+
|
|
346
|
+
The link:{docopslab_git_www}/lab/tree/main/gems/docopslab-dev/README.adoc[DocOps Lab Devtool] or see `.agent/docs/topics/docpslab-devtool.md`.
|
|
347
|
+
|
|
348
|
+
[[api]]
|
|
349
|
+
=== API Design
|
|
350
|
+
|
|
351
|
+
The API is designed to be stable and backward-compatible, with a clear deprecation path for any breaking changes.
|
|
352
|
+
The top-level `Sourcerer.*` methods are deprecated in favor of direct namespace usage (`Sourcerer::Yaml`, `Sourcerer::AsciiDoc`, `Sourcerer::Rendering`), which will be removed in version 1.0.
|
|
353
|
+
|
|
354
|
+
Do not add new public methods directly to the `Sourcerer` namespace;
|
|
355
|
+
instead, add them to the appropriate submodule.
|
|
356
|
+
|
|
357
|
+
Ruby API shape policy::
|
|
358
|
+
Use singleton methods (`def self.*`) on namespace modules for stateless primitives.
|
|
359
|
+
Use classes when behavior is naturally stateful or lifecycle-driven.
|
|
360
|
+
Use mixin modules for host-integration surfaces (for example, Liquid filters/tags) where the host expects instance methods.
|
|
361
|
+
For mixin modules, keep public entrypoints as thin wrappers and place transformation logic in an internal helper module/object.
|
|
362
|
+
|
|
363
|
+
Visibility policy::
|
|
364
|
+
Use `private_class_method` for singleton helper methods defined with `def self.*`.
|
|
365
|
+
Use `private` for instance helper methods in classes or mixins.
|
|
366
|
+
Avoid exporting helper methods as accidental public API.
|
|
367
|
+
|
|
368
|
+
[[tests]]
|
|
369
|
+
=== Tests
|
|
370
|
+
|
|
371
|
+
See the full testing documentation at link:{asciisourcerer_prod_repo_files_path}[`specs/tests/README.adoc`]
|
|
372
|
+
|
|
373
|
+
Run the RSpec suite:
|
|
374
|
+
|
|
375
|
+
[.prompt]
|
|
376
|
+
bundle exec rake rspec
|
|
377
|
+
|
|
378
|
+
Run YAML loader validation:
|
|
379
|
+
|
|
380
|
+
[.prompt]
|
|
381
|
+
bundle exec rake yaml_test
|
|
382
|
+
|
|
383
|
+
Run the PR/CI test suite:
|
|
384
|
+
|
|
385
|
+
[.prompt]
|
|
386
|
+
bundle exec rake pr_test
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
[[legal]]
|
|
390
|
+
== Legal
|
|
391
|
+
|
|
392
|
+
Sourcerer is licensed under the MIT License.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# AsciiSourcerer is the primary entry point for the asciisourcerer gem.
|
|
4
|
+
# It provides an alias to the internal Sourcerer module to avoid namespace
|
|
5
|
+
# conflicts with the unrelated 'sourcerer' gem on RubyGems.org.
|
|
6
|
+
|
|
7
|
+
require_relative 'sourcerer'
|
|
8
|
+
|
|
9
|
+
# Primary module alias for the asciisourcerer gem
|
|
10
|
+
module AsciiSourcerer
|
|
11
|
+
# Transparently delegate all constants and methods to Sourcerer
|
|
12
|
+
def self.const_missing name
|
|
13
|
+
Sourcerer.const_get(name)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.method_missing(method, ...)
|
|
17
|
+
Sourcerer.send(method, ...)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.respond_to_missing? method, include_private = false
|
|
21
|
+
Sourcerer.respond_to?(method, include_private) || super
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Make all Sourcerer submodules available through AsciiSourcerer
|
|
26
|
+
AsciiSourcerer::VERSION = Sourcerer::VERSION
|
|
27
|
+
AsciiSourcerer::AsciiDoc = Sourcerer::AsciiDoc
|
|
28
|
+
AsciiSourcerer::Yaml = Sourcerer::Yaml
|
|
29
|
+
AsciiSourcerer::Rendering = Sourcerer::Rendering
|
|
30
|
+
AsciiSourcerer::Builder = Sourcerer::Builder
|
|
31
|
+
AsciiSourcerer::MarkDownGrade = Sourcerer::MarkDownGrade
|
|
32
|
+
AsciiSourcerer::Jekyll = Sourcerer::Jekyll
|