2024-11-20 21:59:21 +01:00
|
|
|
from pathlib import Path
|
2025-01-04 11:52:37 +01:00
|
|
|
from rougail import Rougail
|
2024-11-20 21:59:21 +01:00
|
|
|
from rougail.config import get_rougail_config
|
|
|
|
from rougail.output_doc import RougailOutputDoc
|
|
|
|
|
|
|
|
|
|
|
|
def _test(modes):
|
|
|
|
test_dir = Path(__file__).resolve().parent
|
|
|
|
rougailconfig = get_rougail_config(backward_compatibility=False)
|
|
|
|
rougailconfig['step.output'] = 'doc'
|
|
|
|
# rougailconfig['tiramisu_cache'] = 'p.py'
|
|
|
|
dirs = [str(test_dir / 'mode')]
|
|
|
|
rougailconfig['modes_level'] = ['basic', 'standard', 'advanced']
|
|
|
|
rougailconfig['main_dictionaries'] = dirs
|
|
|
|
rougailconfig['doc.output_format'] = 'asciidoc'
|
|
|
|
rougailconfig['doc.disabled_modes'] = modes
|
2025-01-04 11:52:37 +01:00
|
|
|
rougail = Rougail(rougailconfig)
|
|
|
|
config = rougail.run()
|
|
|
|
inventory = RougailOutputDoc(config, rougailconfig=rougailconfig)
|
|
|
|
doc = inventory.run()
|
2024-11-20 21:59:21 +01:00
|
|
|
result_file = test_dir / f'mode_{"_".join(modes)}.adoc'
|
|
|
|
if not result_file.is_file():
|
|
|
|
with open(str(result_file), 'w') as docfh:
|
|
|
|
docfh.write(doc)
|
|
|
|
with open(str(result_file)) as docfh:
|
|
|
|
result = docfh.read()
|
|
|
|
assert doc == result
|
|
|
|
|
|
|
|
|
|
|
|
def test_mode_advanced():
|
|
|
|
_test(['basic', 'standard'])
|
|
|
|
|
|
|
|
|
|
|
|
def test_mode_basic_only():
|
|
|
|
_test(['standard', 'advanced'])
|
|
|
|
|
|
|
|
|
|
|
|
def test_mode_standard():
|
|
|
|
_test(['basic', 'advanced'])
|
|
|
|
|
|
|
|
|
|
|
|
def test_mode_standard_advanced():
|
|
|
|
_test(['basic'])
|
|
|
|
|
|
|
|
|
|
|
|
def test_mode_basic_advanced():
|
|
|
|
_test(['standard'])
|
|
|
|
|
|
|
|
|
|
|
|
def test_mode_basic_standard():
|
|
|
|
_test(['advanced'])
|