2009-12-23 04:53:19 -06:00
|
|
|
|
"""Test our handling of metadata in files with bibliographic metadata."""
|
2009-12-21 06:24:33 -06:00
|
|
|
|
|
2009-12-23 04:53:19 -06:00
|
|
|
|
# adapted from an example of bibliographic metadata at
|
2021-05-16 07:42:26 -05:00
|
|
|
|
# https://docutils.sourceforge.io/docs/user/rst/demo.txt
|
2024-11-22 15:54:26 -06:00
|
|
|
|
from __future__ import annotations
|
2009-12-21 06:24:33 -06:00
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
|
import pytest
|
2009-12-21 06:24:33 -06:00
|
|
|
|
|
|
|
|
|
|
2018-11-30 02:56:17 -06:00
|
|
|
|
@pytest.mark.sphinx('dummy', testroot='metadata')
|
2024-07-23 09:35:55 -05:00
|
|
|
|
def test_docinfo(app):
|
2025-01-14 09:55:02 -06:00
|
|
|
|
"""Inspect the 'docinfo' metadata stored in the first node of the document.
|
2009-12-21 23:49:40 -06:00
|
|
|
|
Note this doesn't give us access to data stored in subsequence blocks
|
|
|
|
|
that might be considered document metadata, such as 'abstract' or
|
|
|
|
|
'dedication' blocks, or the 'meta' role. Doing otherwise is probably more
|
|
|
|
|
messing with the internals of sphinx than this rare use case merits.
|
|
|
|
|
"""
|
2018-11-30 02:56:17 -06:00
|
|
|
|
app.build()
|
2009-12-23 04:53:19 -06:00
|
|
|
|
expecteddocinfo = {
|
2018-12-15 08:02:28 -06:00
|
|
|
|
'author': 'David Goodger',
|
|
|
|
|
'authors': ['Me', 'Myself', 'I'],
|
|
|
|
|
'address': '123 Example Street\nExample, EX Canada\nA1B 2C3',
|
|
|
|
|
'field name': 'This is a generic bibliographic field.',
|
2024-08-11 08:58:56 -05:00
|
|
|
|
'field name 2': (
|
|
|
|
|
'Generic bibliographic fields may contain multiple '
|
|
|
|
|
'body elements.\n\nLike this.'
|
|
|
|
|
),
|
2018-12-15 08:02:28 -06:00
|
|
|
|
'status': 'This is a “work in progress”',
|
|
|
|
|
'version': '1',
|
2024-08-11 08:58:56 -05:00
|
|
|
|
'copyright': (
|
|
|
|
|
'This document has been placed in the public domain. '
|
|
|
|
|
'You\nmay do with it as you wish. You may copy, modify,'
|
|
|
|
|
'\nredistribute, reattribute, sell, buy, rent, lease,\n'
|
|
|
|
|
'destroy, or improve it, quote it at length, excerpt,\n'
|
|
|
|
|
'incorporate, collate, fold, staple, or mutilate it, or '
|
|
|
|
|
'do\nanything else to it that your or anyone else’s '
|
|
|
|
|
'heart\ndesires.'
|
|
|
|
|
),
|
2018-12-15 08:02:28 -06:00
|
|
|
|
'contact': 'goodger@python.org',
|
|
|
|
|
'date': '2006-05-21',
|
|
|
|
|
'organization': 'humankind',
|
|
|
|
|
'revision': '4564',
|
2014-08-02 02:39:07 -05:00
|
|
|
|
'tocdepth': 1,
|
2018-12-15 08:02:28 -06:00
|
|
|
|
'orphan': '',
|
|
|
|
|
'nocomments': '',
|
2009-12-23 04:53:19 -06:00
|
|
|
|
}
|
2018-11-30 02:56:17 -06:00
|
|
|
|
assert app.env.metadata['index'] == expecteddocinfo
|