Skip to content

Add markup format option to work queries - #53

Merged
ja573 merged 1 commit into
developfrom
feature/work-query-markup-format
Jul 24, 2026
Merged

Add markup format option to work queries#53
ja573 merged 1 commit into
developfrom
feature/work-query-markup-format

Conversation

@ja573

@ja573 ja573 commented Jul 24, 2026

Copy link
Copy Markdown
Member

Summary

  • add optional markup_format keyword support to work_by_id, work_by_doi, book_by_doi, chapter_by_doi, works, books, and chapters
  • support the case-sensitive GraphQL enum values JATS_XML, PLAIN_TEXT, HTML, and MARKDOWN
  • preserve JATS_XML as the default when the argument is omitted or None
  • reject unsupported and injection-like values with ValueError before any HTTP request
  • prepare package version 1.2.0 and document the public API

Design

Work-query markup formatting belongs to the nested canonical titles(...) and abstracts(...) selections, not to the root work/works field. The generated endpoint helpers therefore consume markup_format as a field-rendering option and pass a fresh per-request field list through the query layer.

Rendering replaces only field entries exactly matching the canonical top-level title and abstract selections. Biographies, related-work titles, additional resources, awards, endorsements, book reviews, and other rich-text fields keep their existing JATS_XML selections.

No static query definition or shared field list is mutated, so sequential requests, multiple clients, concurrent calls, and tests in any order retain independent formatting.

Verification

  • python3 -m unittest thothlibrary.tests.test_queries thothlibrary.tests.test_rest thothlibrary.thoth-1_0_0.tests.tests — 28 tests passed
  • python3 -m compileall -q thothlibrary — passed
  • git diff --check — passed
  • python3 setup.py --version1.2.0

Focused coverage proves the default and PLAIN_TEXT rendering for all seven methods, unquoted HTML/MARKDOWN, restricted transformation, pre-request validation, raw and structured responses, and no state leakage.

Live read-only verification

A credential-free check against https://api.thoth.pub used work e0f748b2-984f-45cc-8b9e-13989c31dda4 with raw=True. Both explicit JATS_XML and PLAIN_TEXT calls succeeded. Three non-empty canonical title/abstract values were inspected: the JATS response retained tags, while the plain-text response contained visible text without JATS tags. No mutation was performed.

Release preparation

This backward-compatible public API addition prepares version 1.2.0. GitHub was checked before the bump: no v1.2.0 tag, release-preparation branch, or issue/PR mentioning 1.2.0 existed. This PR does not create a release or publish to PyPI.

@ja573
ja573 marked this pull request as ready for review July 24, 2026 14:25
@ja573
ja573 merged commit 597f218 into develop Jul 24, 2026
1 check passed
@ja573
ja573 deleted the feature/work-query-markup-format branch July 24, 2026 14:25
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.

1 participant