From: Lady Date: Wed, 24 Dec 2025 19:27:53 +0000 (-0500) Subject: Support “soft” dependencies X-Git-Url: https://git.ladys.computer/Shushe/commitdiff_plain/e7981ed48521a287a0351fb9912cf00a7602dc72?ds=sidebyside;hp=1ba6bb315cf3e1c7120acff6c34149acf65f0120 Support “soft” dependencies From the perspective of Make, these are ordinary dependencies, but they aren’t expanded and so are allowed to be recursive. --- diff --git a/.metadata-format-changed-since b/.metadata-format-changed-since index 36e448c..224e40d 100644 --- a/.metadata-format-changed-since +++ b/.metadata-format-changed-since @@ -4,7 +4,7 @@ SPDX-License-Identifier: CC0-1.0 The following hash indicates a commit in which the metadata format generated by ⛩📰 书社 was different than it currently is :⁠— -d64a8d34c7638243f90421664268766df75a42d7 +1ba6bb315cf3e1c7120acff6c34149acf65f0120 The purpose of this file is to serve as a trackable dependency which will prompt a rebuild of metadata when the generation mechanism diff --git a/GNUmakefile b/GNUmakefile index a3624cc..a883837 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -545,6 +545,7 @@ override dependenciesforfile := $(foreach file,$(filter-out $(assetfiles),$(sour # (callable) Get the list of dependency leiris for the given source files. # # Recursive dependencies are marked with a leading `-´. +# Soft dependencies are marked with a leading `?´. override dependencyuris = $(foreach file,$1,$(subst |, ,$(patsubst $(file)|%,%,$(filter $(file)|%,$(dependenciesforfile))))) # (callable) Get the list of recursive dependencies for the given source files. @@ -555,7 +556,7 @@ override recursives = $(foreach uri,$(filter -%,$(call dependencyuris,$1)),$(cal # (callable) Get the list of (nonrecursive) dependencies for the given source files. # # If the file cannot have dependencies (e·g is an asset file), the resulting value will be the empty string. -override dependencies = $(foreach uri,$(filter-out -%,$(call dependencyuris,$1)),$(call sourcefile,$(uri))) +override dependencies = $(foreach uri,$(filter-out -%,$(call dependencyuris,$1)),$(call sourcefile,$(if $(filter ?%,$(uri)),$(patsubst ?%,%,$(uri)),$(uri)))) endif # Collect all files with recursive dependencies. @@ -624,7 +625,7 @@ install : $(call installed,$(recursivefiles) $(installablefiles)) ; # List all source files and includes and their computed types. list : - @$(PRINTF) '%b' $(call quote,$(foreach file,$(sort $(sourcefiles)) $(sort $(sourceincludes)),\0033[1m$(file)\0033[22m|$(call typeoffile,$(file))|[\0033[3m$(if $(filter $(file),$(xmlfiles)),xml,$(if $(filter $(file),$(plaintextfiles)),text,asset))$(if $(filter $(file),$(sourceincludes)),|include,)\0033[23m]$(if $(call dependencies,$(file))$(call recursives,$(file)), $(strip $(foreach recursive,$(call recursives,$(file)),\0033[93;41m•|Recursive|Dependency|\0033[39;49m|$(recursive)) $(foreach dependency,$(call dependencies,$(file)),\0033[2m•|Dependency|\0033[22m|$(dependency))))$(if $(filter $(file),$(sourcefiles)), $(foreach dest,$(call destination,$(file)),→|<\0033[4m/$(dest)\0033[24m>),) )) | $(TR) ' |' '\n ' + @$(PRINTF) '%b' $(call quote,$(foreach file,$(sort $(sourcefiles)) $(sort $(sourceincludes)),\0033[1m$(file)\0033[22m|$(call typeoffile,$(file))|[\0033[3m$(if $(filter $(file),$(xmlfiles)),xml,$(if $(filter $(file),$(plaintextfiles)),text,asset))$(if $(filter $(file),$(sourceincludes)),|include,)\0033[23m]$(if $(call dependencyuris,$(file)), $(strip $(foreach dep,$(call dependencyuris,$(file)),$(if $(filter -%,$(dep)),\0033[93;41m•|Recursive|Dependency|\0033[39;49m|$(call sourcefile,$(patsubst -%,%,$(dep))),$(if $(filter ?%,$(dep)),\0033[2m•|Soft|Dependency|\0033[22m|$(call sourcefile,$(patsubst ?%,%,$(dep))),\0033[2m•|Dependency|\0033[22m|$(call sourcefile,$(dep)))))))$(if $(filter $(file),$(sourcefiles)), $(foreach dest,$(call destination,$(file)),→|<\0033[4m/$(dest)\0033[24m>),) )) | $(TR) ' |' '\n ' # Lists out the destinations of all resulting files (relative to `DESTDIR´). listout : diff --git a/README.markdown b/README.markdown index 4671064..be400b9 100644 --- a/README.markdown +++ b/README.markdown @@ -575,7 +575,8 @@ The file is retransformed each time, with the value of the `DESTINATION` global ## Embedding Documents can be embedded in other documents using a `<书社:link>` - element with `@xlink:show="embed"`. + element with `@xlink:show="embed"` and an `@xlink:actuate` which is + absent or `"none"`. The `@xlink:href`s of these elements should have the format `about:shushe?source=`, where `` provides the path to the file within `SRCDIR`. @@ -583,6 +584,8 @@ Includes, which do not generate outputs of their own but may still be freely embedded, instead use the format `about:shushe?include=`, where `` provides the path within `INCLUDEDIR`. +If `` indicates a directory and ends with a slash (`/`), + everything within that directory will be embedded. Embeds are replaced with the parsed contents of a file, unless the file is an asset, in which case an `` element is produced @@ -622,6 +625,40 @@ These include :⁠— These attributes are used to scope any nested `` elements with `@itemprop` attributes to their containing documents. +## Soft Dependencies + +When a file depends only on the metadata of another file, and not its + contents, it can be added as a soft dependency rather than an embed. +Soft dependencies are indicated using a `<书社:link>` element with an + `@xlink:show` of `"other"`, `"none"`, or absent, and an + `@xlink:actuate` which is absent or `"none"`. +A change to a soft dependency requires a file to be rebuilt, but no + embedding occurs automatically. +Because there is no automatic embedding, soft dependencies are allowed + to be recursive. + +The `@xlink:href`s of soft dependency `<书社:link>`s are processed in + exactly the same fashion as embeds, described above. + +If the value of `@xlink:show` is `"other"`, the soft dependency is + transitive. +Any dependencies of the indicated file which have a `@name` which + matches that of the referencing `<书社:link>` element will also be + treated as soft dependencies. +If no `@name` is given, it is treated as the empty string. + +When a document is embedded directly, all of its soft dependencies are + also treated as soft dependencies of the embedding object. +However, a document is embedded in a transitive soft dependency, the + embed is treated exactly as tho it were itself a transitive soft + dependency. +That means it must have a matching `@name` to be included, and + like·wise for any embeds or soft dependencies it contains. + +If the value of `@xlink:show` is `"none"` or absent, the soft + dependency is not transitive and its own dependencies are not + checked. + ## Transforms Transforms are used to convert X·M·L files into their final output, diff --git a/lib/expandmetadata.xslt b/lib/expandmetadata.xslt index 423924a..727d58a 100644 --- a/lib/expandmetadata.xslt +++ b/lib/expandmetadata.xslt @@ -26,53 +26,126 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one > -