bandwidth and initial processing time. If
not set, :py:`False` is used. See
`Search options`_ for more information.
+:py:`SEARCH_FILENAME_PREFIX: str` Search data filename prefix. Useful to
+ prevent file conflicts if both C++ and
+ Python documentation shares the same
+ directory. If not set, ``searchdata`` is
+ used.
:py:`SEARCH_HELP: str` HTML code to display as help text on empty
search popup. If not set, a default message
is used. Has effect only if
:ini:`M_MATH_CACHE_FILE` :py:`M_MATH_CACHE_FILE`
:ini:`M_SEARCH_DISABLED` :py:`SEARCH_DISABLED`
:ini:`M_SEARCH_DOWNLOAD_BINARY` :py:`SEARCH_DOWNLOAD_BINARY`
+ :ini:`M_SEARCH_FILENAME_PREFIX` :py:`SEARCH_FILENAME_PREFIX`
:ini:`M_SEARCH_HELP` :py:`SEARCH_HELP`
:ini:`M_SEARCH_BASE_URL` :py:`SEARCH_BASE_URL`
:ini:`M_SEARCH_EXTERNAL_URL` :py:`SEARCH_EXTERNAL_URL`
bandwidth and initial processing time. If
not set, :py:`False` is used. See `Search options`_
for more information.
+:py:`SEARCH_FILENAME_PREFIX: str` Search data filename prefix. Useful to
+ prevent file conflicts if both C++ and
+ Python documentation shares the same
+ directory. If not set, ``searchdata`` is
+ used.
:py:`SEARCH_HELP: str` :abbr:`reST <reStructuredText>` markup to
display as help text on empty search popup.
If not set, a default message is used. Has
# Version 0 was without the type map
searchdata_format_version = 1
search_filename = f'search-v{searchdata_format_version}.js'
-searchdata_filename = f'searchdata-v{searchdata_format_version}.bin'
-searchdata_filename_b85 = f'searchdata-v{searchdata_format_version}.js'
+searchdata_filename = f'{{search_filename_prefix}}-v{searchdata_format_version}.bin'
+searchdata_filename_b85 = f'{{search_filename_prefix}}-v{searchdata_format_version}.js'
class CssClass(enum.Enum):
DEFAULT = 0
'SEARCH_DISABLED': False,
'SEARCH_DOWNLOAD_BINARY': False,
+ 'SEARCH_FILENAME_PREFIX': 'searchdata',
'SEARCH_HELP':
"""<p class="m-noindent">Search for symbols, directories, files, pages or
modules. You can omit any prefix from the symbol or file path; adding a
('M_SEARCH_DISABLED', 'SEARCH_DISABLED', bool),
('M_SEARCH_DOWNLOAD_BINARY', 'SEARCH_DOWNLOAD_BINARY', bool),
+ ('M_SEARCH_FILENAME_PREFIX', 'SEARCH_FILENAME_PREFIX', str),
('M_SEARCH_HELP', 'SEARCH_HELP', str),
('M_SEARCH_BASE_URL', 'SEARCH_BASE_URL', str),
('M_SEARCH_EXTERNAL_URL', 'SEARCH_EXTERNAL_URL', str),
data = build_search_data(state, add_lookahead_barriers=search_add_lookahead_barriers, merge_subtrees=search_merge_subtrees, merge_prefixes=search_merge_prefixes)
if state.config['SEARCH_DOWNLOAD_BINARY']:
- with open(os.path.join(html_output, searchdata_filename), 'wb') as f:
+ with open(os.path.join(html_output, searchdata_filename.format(search_filename_prefix=state.config['SEARCH_FILENAME_PREFIX'])), 'wb') as f:
f.write(data)
else:
- with open(os.path.join(html_output, searchdata_filename_b85), 'wb') as f:
+ with open(os.path.join(html_output, searchdata_filename_b85.format(search_filename_prefix=state.config['SEARCH_FILENAME_PREFIX'])), 'wb') as f:
f.write(base85encode_search_data(data))
# OpenSearch metadata, in case we have the base URL
'SEARCH_DISABLED': False,
'SEARCH_DOWNLOAD_BINARY': False,
+ 'SEARCH_FILENAME_PREFIX': 'searchdata',
'SEARCH_HELP': """.. raw:: html
<p class="m-noindent">Search for modules, classes, functions and other
# TODO: any chance we could write the file *before* it gets ever passed
# to URL formatters so we can add cache buster hashes to its URL?
if state.config['SEARCH_DOWNLOAD_BINARY']:
- with open(os.path.join(config['OUTPUT'], config['URL_FORMATTER'](EntryType.STATIC, [os.path.join(config['OUTPUT'], state.config['SEARCH_DOWNLOAD_BINARY'] if isinstance(state.config['SEARCH_DOWNLOAD_BINARY'], str) else searchdata_filename)])[0]), 'wb') as f:
+ with open(os.path.join(config['OUTPUT'], config['URL_FORMATTER'](EntryType.STATIC, [os.path.join(config['OUTPUT'], state.config['SEARCH_DOWNLOAD_BINARY'] if isinstance(state.config['SEARCH_DOWNLOAD_BINARY'], str) else searchdata_filename.format(search_filename_prefix=state.config['SEARCH_FILENAME_PREFIX']))])[0]), 'wb') as f:
f.write(data)
else:
- with open(os.path.join(config['OUTPUT'], config['URL_FORMATTER'](EntryType.STATIC, [os.path.join(config['OUTPUT'], searchdata_filename_b85)])[0]), 'wb') as f:
+ with open(os.path.join(config['OUTPUT'], config['URL_FORMATTER'](EntryType.STATIC, [os.path.join(config['OUTPUT'], searchdata_filename_b85.format(search_filename_prefix=state.config['SEARCH_FILENAME_PREFIX']))])[0]), 'wb') as f:
f.write(base85encode_search_data(data))
# OpenSearch metadata, in case we have the base URL
<script src="search-v{{ SEARCHDATA_FORMAT_VERSION }}.js"></script>
{% if SEARCH_DOWNLOAD_BINARY %}
<script>
- Search.download(window.location.pathname.substr(0, window.location.pathname.lastIndexOf('/') + 1) + 'searchdata-v{{ SEARCHDATA_FORMAT_VERSION }}.bin');
+ Search.download(window.location.pathname.substr(0, window.location.pathname.lastIndexOf('/') + 1) + '{{ SEARCH_FILENAME_PREFIX }}-v{{ SEARCHDATA_FORMAT_VERSION }}.bin');
</script>
{% else %}
-<script src="searchdata-v{{ SEARCHDATA_FORMAT_VERSION }}.js" async="async"></script>
+<script src="{{ SEARCH_FILENAME_PREFIX }}-v{{ SEARCHDATA_FORMAT_VERSION }}.js" async="async"></script>
{% endif %}
{% endif %}
{% if FINE_PRINT %}
<script src="{{ 'search.js'|format_url|e }}"></script>
{% if SEARCH_DOWNLOAD_BINARY %}
<script>
- Search.download({% if SEARCH_DOWNLOAD_BINARY is string %}'{{ SEARCH_DOWNLOAD_BINARY.format(SEARCHDATA_FORMAT_VERSION)|format_url|e }}'{% else %}window.location.pathname.substr(0, window.location.pathname.lastIndexOf('/') + 1) + 'searchdata-v{{ SEARCHDATA_FORMAT_VERSION }}.bin'{% endif %});
+ Search.download({% if SEARCH_DOWNLOAD_BINARY is string %}'{{ SEARCH_DOWNLOAD_BINARY.format(SEARCHDATA_FORMAT_VERSION)|format_url|e }}'{% else %}window.location.pathname.substr(0, window.location.pathname.lastIndexOf('/') + 1) + '{{ SEARCH_FILENAME_PREFIX }}-v{{ SEARCHDATA_FORMAT_VERSION }}.bin'{% endif %});
</script>
{% else %}
-<script src="{{ 'searchdata-v{}.js'.format(SEARCHDATA_FORMAT_VERSION)|format_url|e }}" async="async"></script>
+<script src="{{ '{}-v{}.js'.format(SEARCH_FILENAME_PREFIX, SEARCHDATA_FORMAT_VERSION)|format_url|e }}" async="async"></script>
{% endif %}
{% endif %}
{% if FINE_PRINT %}
##! M_LINKS_NAVBAR1 =
##! M_LINKS_NAVBAR2 =
##! M_SEARCH_DOWNLOAD_BINARY = YES
+##! M_SEARCH_FILENAME_PREFIX = secretblob
'SEARCH_DISABLED': False,
'SEARCH_DOWNLOAD_BINARY': False,
+ 'SEARCH_FILENAME_PREFIX': 'searchdata',
'SEARCH_BASE_URL': None,
'SEARCH_EXTERNAL_URL': None,
'SEARCH_HELP':
self.assertEqual(*self.actual_expected_contents('pages.html'))
self.assertTrue(os.path.exists(os.path.join(self.path, 'html', 'm-dark+documentation.compiled.css')))
self.assertTrue(os.path.exists(os.path.join(self.path, 'html', search_filename)))
- self.assertTrue(os.path.exists(os.path.join(self.path, 'html', searchdata_filename_b85)))
+ self.assertTrue(os.path.exists(os.path.join(self.path, 'html', searchdata_filename_b85.format(search_filename_prefix='searchdata'))))
self.assertTrue(os.path.exists(os.path.join(self.path, 'html', 'favicon-light.png')))
class GeneratedDoxyfile(BaseTestCase):
def test(self):
self.run_doxygen(wildcard='indexpage.xml')
self.assertEqual(*self.actual_expected_contents('index.html'))
- self.assertTrue(os.path.exists(os.path.join(self.path, 'html', searchdata_filename)))
+ self.assertTrue(os.path.exists(os.path.join(self.path, 'html', searchdata_filename.format(search_filename_prefix='searchdata'))))
class SearchOpensearch(BaseTestCase):
def test(self):
def test(self):
self.run_doxygen(index_pages=[], wildcard='*.xml')
- with open(os.path.join(self.path, 'html', searchdata_filename), 'rb') as f:
+ with open(os.path.join(self.path, 'html', searchdata_filename.format(search_filename_prefix='secretblob')), 'rb') as f:
serialized = f.read()
search_data_pretty = pretty_print(serialized, entryTypeClass=EntryType)[0]
#print(search_data_pretty)
def test(self):
self.run_doxygen(index_pages=[], wildcard='*.xml')
- with open(os.path.join(self.path, 'html', searchdata_filename), 'rb') as f:
+ with open(os.path.join(self.path, 'html', searchdata_filename.format(search_filename_prefix='searchdata')), 'rb') as f:
serialized = f.read()
search_data_pretty = pretty_print(serialized, entryTypeClass=EntryType)[0]
#print(search_data_pretty)
# Test we have all symbols in search data. It's enough to assert the
# count, it equal to symbol count in the header file
# TODO: reuse the search data deserialization API once done
- with open(os.path.join(self.path, 'html', searchdata_filename), 'rb') as f:
+ with open(os.path.join(self.path, 'html', searchdata_filename.format(search_filename_prefix='searchdata')), 'rb') as f:
serialized = f.read()
magic, version, symbol_count, map_offset, type_map_offset = search_data_header_struct.unpack_from(serialized)
self.assertEqual(symbol_count, 44)
self.assertTrue(os.path.exists(os.path.join(self.path, 'output/m-dark+documentation.compiled.css')))
self.assertTrue(os.path.exists(os.path.join(self.path, 'output/favicon-light.png')))
self.assertTrue(os.path.exists(os.path.join(self.path, 'output/search-v{}.js'.format(searchdata_format_version))))
- self.assertTrue(os.path.exists(os.path.join(self.path, 'output', searchdata_filename_b85)))
+ self.assertTrue(os.path.exists(os.path.join(self.path, 'output', searchdata_filename_b85.format(search_filename_prefix='searchdata'))))
self.assertTrue(os.path.exists(os.path.join(self.path, 'output/sitemap.xml')))
class SearchBinary(BaseTestCase):
})
self.assertEqual(*self.actual_expected_contents('index.html'))
self.assertTrue(os.path.exists(os.path.join(self.path, 'output', 'search-v{}.js'.format(searchdata_format_version))))
- self.assertTrue(os.path.exists(os.path.join(self.path, 'output', searchdata_filename)))
+ self.assertTrue(os.path.exists(os.path.join(self.path, 'output', searchdata_filename.format(search_filename_prefix='searchdata'))))
class SearchOpenSearch(BaseTestCase):
def test(self):
self.run_python({
'SEARCH_DISABLED': False,
'SEARCH_DOWNLOAD_BINARY': True,
+ 'SEARCH_FILENAME_PREFIX': 'secretblob',
'PYBIND11_COMPATIBILITY': True
})
- with open(os.path.join(self.path, 'output', searchdata_filename), 'rb') as f:
+ with open(os.path.join(self.path, 'output', searchdata_filename.format(search_filename_prefix='secretblob')), 'rb') as f:
serialized = f.read()
search_data_pretty = pretty_print(serialized, entryTypeClass=EntryType)[0]
#print(search_data_pretty)
'PYBIND11_COMPATIBILITY': True
})
- with open(os.path.join(self.path, 'output', searchdata_filename), 'rb') as f:
+ with open(os.path.join(self.path, 'output', searchdata_filename.format(search_filename_prefix='searchdata')), 'rb') as f:
serialized = f.read()
search_data_pretty = pretty_print(serialized, entryTypeClass=EntryType)[0]
#print(search_data_pretty)