Make auto-relinker's error message clearer

This commit is contained in:
Griatch 2020-06-18 01:13:02 +02:00
parent f2d460672e
commit 687c1e91f5

View file

@ -6,6 +6,7 @@ directive somewhere.
""" """
import re import re
from sphinx.errors import DocumentError
from pathlib import Path from pathlib import Path
from os.path import abspath, dirname, join as pathjoin, sep from os.path import abspath, dirname, join as pathjoin, sep
@ -34,8 +35,10 @@ def create_toctree():
url = url.rsplit(".", 1)[0] url = url.rsplit(".", 1)[0]
fname = fname.rsplit(".", 1)[0] fname = fname.rsplit(".", 1)[0]
if fname in docref_map: if fname in docref_map:
raise RuntimeError(f"'{url}' and '{docref_map[fname]}': Auto-link correction does not " raise DocumentError(
"accept doc-files with the same name, even in different folders.") f" Tried to add '{url}.md' when '{docref_map[fname]}.md' already exists.\n"
" Evennia's auto-link-corrector does not accept doc-files with the same \n"
" name, even in different folders. Rename one.\n")
docref_map[fname] = url docref_map[fname] = url
# normal reference-links [txt](urls) # normal reference-links [txt](urls)