Skip to content

Support sub-attribute selection for structured attributes in publish configuration - #830

Merged
jacebrowning merged 5 commits into
doorstop-dev:developfrom
opt12:sub-attribute-selection-for-structured-attributes
Aug 26, 2026
Merged

Support sub-attribute selection for structured attributes in publish configuration#830
jacebrowning merged 5 commits into
doorstop-dev:developfrom
opt12:sub-attribute-selection-for-structured-attributes

Conversation

@opt12

@opt12 opt12 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Closes: #829


Summary

The publish list in .doorstop.yml previously only supported simple string attribute names. Publishing structured attributes (list of dicts) resulted in a raw Python object dump in the output table. This MR extends the publish configuration to allow selecting specific sub-attributes for rendering, including hyperlink support with combined labels.


Changes

doorstop/core/publishers/markdown.py

  • Added _parse_publish_entry() – parses publish list entries; backward compatible: string entries behave as before, dict entries use the attribute name directly as key with a fields configuration
  • Added _render_fields() – renders selected sub-attributes of structured attributes as Markdown links or plain text; supports single-field labels (url: section), combined multi-field labels (url: {label: [file, section], separator: ": "}), and plain text fields; multiple entries joined with <br>
  • Modified _lines_markdown():
    • publish list now supports both string and dict entries
    • plain list attributes joined with <br> instead of raw Python list dump
    • trailing yield "" only emitted when table was actually printed

docs/reference/item.md

  • Minor wording fix: removed redundant "key and value" in existing sentence
  • Added documentation for list attribute rendering (<br> separator)
  • Added new section "Publishing sub-attributes of structured attributes" with syntax reference, fields format table, single-field and combined-label examples

doorstop/core/publishers/tests/helpers.py

  • Added YAML_STRUCTURED_ATTRIBUTES – document config with structured spec-refs-from publish entry
  • Added YAML_COMBINED_LABEL_ATTRIBUTES – document config with combined label publish entry
  • Added YAML_LIST_ATTRIBUTE – document config with plain list attribute
  • Added YAML_INVALID_PUBLISH_ENTRY – document config with attr: ~ for edge case testing

doorstop/core/publishers/tests/test_publisher_markdown.py

  • Added import of MarkdownPublisher
  • Added TestParsePublishEntry – 5 unit tests for _parse_publish_entry()
  • Added TestRenderFields – 14 unit tests for _render_fields(), including combined label and separator variants
  • Added TestPublishLinesCustomAttributesExtended – 8 integration tests covering all new code paths in _lines_markdown()

New .doorstop.yml syntax

attributes:
  publish:
    - simple-attribute          # existing behavior – unchanged
    - spec-refs-from:           # structured attribute
        fields:
          - url: section        # single field as link text
    - spec-refs-to:
        fields:
          - url:
              label: [file, section]   # combined label
              separator: ": "          # optional, default: ": "

Backward Compatibility

Fully backward compatible. All existing string entries in publish behave exactly as before.


Testing

867 existing tests pass. 25 new tests added.

@jacebrowning
jacebrowning merged commit cf949cb into doorstop-dev:develop Aug 26, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants