|
|
|
@ -18,6 +18,11 @@ import bs4 as soup
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#=== CONFIG ============================================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
repository = 'marzer/tomlplusplus'
|
|
|
|
|
inline_namespaces = [
|
|
|
|
|
"toml::literals",
|
|
|
|
|
]
|
|
|
|
@ -92,6 +97,173 @@ string_literals = [
|
|
|
|
|
'sv',
|
|
|
|
|
'_toml'
|
|
|
|
|
]
|
|
|
|
|
external_links = [
|
|
|
|
|
(r'static_cast','https://en.cppreference.com/w/cpp/language/static_cast'),
|
|
|
|
|
(r'const_cast','https://en.cppreference.com/w/cpp/language/const_cast'),
|
|
|
|
|
(r'dynamic_cast','https://en.cppreference.com/w/cpp/language/dynamic_cast'),
|
|
|
|
|
(r'reinterpret_cast','https://en.cppreference.com/w/cpp/language/reinterpret_cast'),
|
|
|
|
|
(r'(?:std::)?size_t', 'https://en.cppreference.com/w/cpp/types/size_t'),
|
|
|
|
|
(r'(?:std::)?u?int(_fast|_least)?(?:8|16|32|64)_ts?', 'https://en.cppreference.com/w/cpp/types/integer'),
|
|
|
|
|
(r'std::pairs?', 'https://en.cppreference.com/w/cpp/utility/pair'),
|
|
|
|
|
(r'std::bytes?', 'https://en.cppreference.com/w/cpp/types/byte'),
|
|
|
|
|
(r'std::optionals?', 'https://en.cppreference.com/w/cpp/utility/optional'),
|
|
|
|
|
(r'std::tuples?', 'https://en.cppreference.com/w/cpp/utility/tuple'),
|
|
|
|
|
(r'std::integral_constants?', 'https://en.cppreference.com/w/cpp/types/integral_constant'),
|
|
|
|
|
(r'std::char_traits', 'https://en.cppreference.com/w/cpp/string/char_traits'),
|
|
|
|
|
(r'std::allocators?', 'https://en.cppreference.com/w/cpp/memory/allocator'),
|
|
|
|
|
(r'std::enable_if(?:_t)?', 'https://en.cppreference.com/w/cpp/types/enable_if'),
|
|
|
|
|
(r'std::conditional(?:_t)?', 'https://en.cppreference.com/w/cpp/types/conditional'),
|
|
|
|
|
(r'std::unordered_maps?', 'https://en.cppreference.com/w/cpp/container/unordered_map'),
|
|
|
|
|
(r'std::unordered_sets?', 'https://en.cppreference.com/w/cpp/container/unordered_set'),
|
|
|
|
|
(r'std::maps?', 'https://en.cppreference.com/w/cpp/container/map'),
|
|
|
|
|
(r'std::sets?', 'https://en.cppreference.com/w/cpp/container/set'),
|
|
|
|
|
(r'std::vectors?', 'https://en.cppreference.com/w/cpp/container/vector'),
|
|
|
|
|
(r'std::arrays?', 'https://en.cppreference.com/w/cpp/container/array'),
|
|
|
|
|
(r'std::chrono::durations?', 'https://en.cppreference.com/w/cpp/chrono/duration'),
|
|
|
|
|
(
|
|
|
|
|
r'std::atomic(?:_(?:'
|
|
|
|
|
+ r'bool|[su]?char(?:8_t|16_t|32_t)?|u?short'
|
|
|
|
|
+ r'|u?int(?:8_t|16_t|32_t|64_t)?|u?l?long'
|
|
|
|
|
+ r'))?',
|
|
|
|
|
'https://en.cppreference.com/w/cpp/atomic/atomic'
|
|
|
|
|
),
|
|
|
|
|
(r'std::unique_ptrs?', 'https://en.cppreference.com/w/cpp/memory/unique_ptr'),
|
|
|
|
|
(r'std::shared_ptrs?', 'https://en.cppreference.com/w/cpp/memory/shared_ptr'),
|
|
|
|
|
(r'(?:std::)?nullptr_t', 'https://en.cppreference.com/w/cpp/types/nullptr_t'),
|
|
|
|
|
(r'std::reverse_iterator', 'https://en.cppreference.com/w/cpp/iterator/reverse_iterator'),
|
|
|
|
|
(r'std::(?:basic_|w)?istreams?', 'https://en.cppreference.com/w/cpp/io/basic_istream'),
|
|
|
|
|
(r'std::(?:basic_|w)?ostreams?', 'https://en.cppreference.com/w/cpp/io/basic_ostream'),
|
|
|
|
|
(r'std::(?:basic_|w)?iostreams?', 'https://en.cppreference.com/w/cpp/io/basic_iostream'),
|
|
|
|
|
(r'std::(?:basic_|w)?ifstreams?', 'https://en.cppreference.com/w/cpp/io/basic_ifstream'),
|
|
|
|
|
(r'std::(?:basic_|w)?ofstreams?', 'https://en.cppreference.com/w/cpp/io/basic_ofstream'),
|
|
|
|
|
(r'std::(?:basic_|w)?fstreams?', 'https://en.cppreference.com/w/cpp/io/basic_fstream'),
|
|
|
|
|
(r'std::(?:basic_|w)?istringstreams?', 'https://en.cppreference.com/w/cpp/io/basic_istringstream'),
|
|
|
|
|
(r'std::(?:basic_|w)?ostringstreams?', 'https://en.cppreference.com/w/cpp/io/basic_ostringstream'),
|
|
|
|
|
(r'std::(?:basic_|w)?stringstreams?', 'https://en.cppreference.com/w/cpp/io/basic_stringstream'),
|
|
|
|
|
(r'std::(?:basic_|w|u(?:8|16|32))?string_views?', 'https://en.cppreference.com/w/cpp/string/basic_string_view'),
|
|
|
|
|
(r'std::(?:basic_|w|u(?:8|16|32))?strings?', 'https://en.cppreference.com/w/cpp/string/basic_string'),
|
|
|
|
|
(r'\s(?:<|<)fstream(?:>|>)', 'https://en.cppreference.com/w/cpp/header/fstream'),
|
|
|
|
|
(r'\s(?:<|<)sstream(?:>|>)', 'https://en.cppreference.com/w/cpp/header/sstream'),
|
|
|
|
|
(r'\s(?:<|<)iostream(?:>|>)', 'https://en.cppreference.com/w/cpp/header/iostream'),
|
|
|
|
|
(r'\s(?:<|<)iosfwd(?:>|>)', 'https://en.cppreference.com/w/cpp/header/iosfwd'),
|
|
|
|
|
(r'\s(?:<|<)string(?:>|>)', 'https://en.cppreference.com/w/cpp/header/string'),
|
|
|
|
|
(r'\s(?:<|<)string_view(?:>|>)', 'https://en.cppreference.com/w/cpp/header/string_view'),
|
|
|
|
|
(r'(?:wchar|char(?:8|16|32))_ts?', 'https://en.cppreference.com/w/cpp/language/types#Character_types'),
|
|
|
|
|
(r'std::is_(?:nothrow_)?convertible(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_convertible'),
|
|
|
|
|
(r'std::is_same(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_same'),
|
|
|
|
|
(r'std::is_base_of(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_base_of'),
|
|
|
|
|
(r'std::is_enum(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_enum'),
|
|
|
|
|
(r'std::is_floating_point(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_floating_point'),
|
|
|
|
|
(r'std::is_integral(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_integral'),
|
|
|
|
|
(r'std::is_pointer(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_pointer'),
|
|
|
|
|
(r'std::is_reference(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_reference'),
|
|
|
|
|
(r'std::is_signed(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_signed'),
|
|
|
|
|
(r'std::is_unsigned(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_unsigned'),
|
|
|
|
|
(r'std::is_void(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_void'),
|
|
|
|
|
(r'std::is_(?:nothrow_)?invocable(?:_r)?', 'https://en.cppreference.com/w/cpp/types/is_invocable'),
|
|
|
|
|
(r'std::add_[lr]value_reference(?:_t)?', 'https://en.cppreference.com/w/cpp/types/add_reference'),
|
|
|
|
|
(r'std::remove_reference(?:_t)?', 'https://en.cppreference.com/w/cpp/types/remove_reference'),
|
|
|
|
|
(r'std::remove_cv(?:_t)?', 'https://en.cppreference.com/w/cpp/types/remove_cv'),
|
|
|
|
|
(r'std::underlying_type(?:_t)?', 'https://en.cppreference.com/w/cpp/types/underlying_type'),
|
|
|
|
|
(r'std::exceptions?', 'https://en.cppreference.com/w/cpp/error/exception'),
|
|
|
|
|
(r'std::runtime_errors?', 'https://en.cppreference.com/w/cpp/error/runtime_error'),
|
|
|
|
|
(r'std::is_constant_evaluated', 'https://en.cppreference.com/w/cpp/types/is_constant_evaluated'),
|
|
|
|
|
(r'std::launder', 'https://en.cppreference.com/w/cpp/utility/launder'),
|
|
|
|
|
(r'std::bit_width', 'https://en.cppreference.com/w/cpp/numeric/bit_width'),
|
|
|
|
|
(r'std::bit_ceil', 'https://en.cppreference.com/w/cpp/numeric/bit_ceil'),
|
|
|
|
|
(r'std::bit_floor', 'https://en.cppreference.com/w/cpp/numeric/bit_floor'),
|
|
|
|
|
(r'std::bit_cast', 'https://en.cppreference.com/w/cpp/numeric/bit_cast'),
|
|
|
|
|
(r'std::countl_zero', 'https://en.cppreference.com/w/cpp/numeric/countl_zero'),
|
|
|
|
|
(r'std::countr_zero', 'https://en.cppreference.com/w/cpp/numeric/countr_zero'),
|
|
|
|
|
(r'std::countl_one', 'https://en.cppreference.com/w/cpp/numeric/countl_one'),
|
|
|
|
|
(r'std::countr_one', 'https://en.cppreference.com/w/cpp/numeric/countr_one'),
|
|
|
|
|
(r'std::popcount', 'https://en.cppreference.com/w/cpp/numeric/popcount'),
|
|
|
|
|
(r'std::has_single_bit', 'https://en.cppreference.com/w/cpp/numeric/has_single_bit'),
|
|
|
|
|
(r'std::min', 'https://en.cppreference.com/w/cpp/algorithm/min'),
|
|
|
|
|
(r'std::max', 'https://en.cppreference.com/w/cpp/algorithm/max'),
|
|
|
|
|
(r'std::clamp', 'https://en.cppreference.com/w/cpp/algorithm/clamp'),
|
|
|
|
|
(r'std::numeric_limits', 'https://en.cppreference.com/w/cpp/types/numeric_limits'),
|
|
|
|
|
(r'std::initializer_lists?', 'https://en.cppreference.com/w/cpp/utility/initializer_list'),
|
|
|
|
|
(
|
|
|
|
|
r'(?:L?P)?(?:'
|
|
|
|
|
+ r'D?WORD(?:32|64|_PTR)?|HANDLE|HMODULE|BOOL(?:EAN)?'
|
|
|
|
|
+ r'|U?SHORT|U?LONG|U?INT(?:8|16|32|64)?'
|
|
|
|
|
+ r'|BYTE|VOID|C[WT]?STR'
|
|
|
|
|
+ r')',
|
|
|
|
|
'https://docs.microsoft.com/en-us/windows/desktop/winprog/windows-data-types'
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
r'(?:__INTELLISENSE__|_MSC_FULL_VER|_MSC_VER|_MSVC_LANG|_WIN32|_WIN64)',
|
|
|
|
|
'https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2019'
|
|
|
|
|
),
|
|
|
|
|
(r'IUnknowns?', 'https://docs.microsoft.com/en-us/windows/win32/api/unknwn/nn-unknwn-iunknown'),
|
|
|
|
|
(r'(?:IUnknown::)?QueryInterface?', 'https://docs.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-queryinterface(q)'),
|
|
|
|
|
(r'(?:Legacy)?InputIterators?', 'https://en.cppreference.com/w/cpp/named_req/InputIterator'),
|
|
|
|
|
(r'(?:Legacy)?OutputIterators?', 'https://en.cppreference.com/w/cpp/named_req/OutputIterator'),
|
|
|
|
|
(r'(?:Legacy)?ForwardIterators?', 'https://en.cppreference.com/w/cpp/named_req/ForwardIterator'),
|
|
|
|
|
(r'(?:Legacy)?BidirectionalIterators?', 'https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator'),
|
|
|
|
|
(r'(?:Legacy)?RandomAccessIterators?', 'https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator'),
|
|
|
|
|
(r'(?:Legacy)?ContiguousIterators?', 'https://en.cppreference.com/w/cpp/named_req/ContiguousIterator'),
|
|
|
|
|
(
|
|
|
|
|
r'(?:'
|
|
|
|
|
+ r'__cplusplus|__STDC_HOSTED__'
|
|
|
|
|
+ r'|__FILE__|__LINE__'
|
|
|
|
|
+ r'|__DATE__|__TIME__'
|
|
|
|
|
+ r'|__STDCPP_DEFAULT_NEW_ALIGNMENT__'
|
|
|
|
|
+ r')',
|
|
|
|
|
'https://en.cppreference.com/w/cpp/preprocessor/replace'
|
|
|
|
|
),
|
|
|
|
|
# toml-specific
|
|
|
|
|
(r'toml::values?', 'classtoml_1_1value.html'),
|
|
|
|
|
(r'(toml::)?date_times?', 'structtoml_1_1date__time.html'),
|
|
|
|
|
(r'(toml::)?time', 'structtoml_1_1time.html'),
|
|
|
|
|
(r'(toml::)?dates?', 'structtoml_1_1date.html')
|
|
|
|
|
]
|
|
|
|
|
header_overrides = [
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
|
badges = [
|
|
|
|
|
(
|
|
|
|
|
'Releases',
|
|
|
|
|
'https://img.shields.io/github/v/release/marzer/tomlplusplus?style=flat-square',
|
|
|
|
|
'https://github.com/marzer/tomlplusplus/releases'
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
'C++17',
|
|
|
|
|
'badge-C++17.svg',
|
|
|
|
|
'https://en.cppreference.com/w/cpp/compiler_support'
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
'C++20',
|
|
|
|
|
'badge-C++20.svg',
|
|
|
|
|
'https://en.cppreference.com/w/cpp/compiler_support'
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
'TOML v1.0.0-rc.1',
|
|
|
|
|
'badge-TOML.svg',
|
|
|
|
|
'https://toml.io/en/v1.0.0-rc.1'
|
|
|
|
|
),
|
|
|
|
|
(None, None, None), # <br>
|
|
|
|
|
(
|
|
|
|
|
'MIT License',
|
|
|
|
|
'badge-license-MIT.svg',
|
|
|
|
|
'https://github.com/marzer/tomlplusplus/blob/master/LICENSE'
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
'CircleCI',
|
|
|
|
|
'https://img.shields.io/circleci/build/github/marzer/tomlplusplus'
|
|
|
|
|
+ '?label=circle%20ci&logo=circleci&logoColor=white&style=flat-square',
|
|
|
|
|
'https://circleci.com/gh/marzer/tomlplusplus'
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
'Mentioned in Awesome C++',
|
|
|
|
|
'badge-awesome.svg',
|
|
|
|
|
'https://github.com/fffaraz/awesome-cpp'
|
|
|
|
|
)
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#=== HTML DOCUMENT =====================================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -113,7 +285,7 @@ class HTMLDocument(object):
|
|
|
|
|
def flush(self):
|
|
|
|
|
with open(self.__path, 'w', encoding='utf-8', newline='\n') as f:
|
|
|
|
|
f.write(str(self.__doc))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def new_tag(self, name, parent=None, string=None, class_=None, index=None, before=None, after=None, **kwargs):
|
|
|
|
|
tag = self.__doc.new_tag(name, **kwargs)
|
|
|
|
|
if (string is not None):
|
|
|
|
@ -132,7 +304,7 @@ class HTMLDocument(object):
|
|
|
|
|
parent.append(tag)
|
|
|
|
|
else:
|
|
|
|
|
parent.insert(index, tag)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return tag
|
|
|
|
|
|
|
|
|
|
def find_all_from_sections(self, name=None, select=None, section=None, include_toc=False, **kwargs):
|
|
|
|
@ -164,7 +336,7 @@ def html_find_parent(tag, names, cutoff=None):
|
|
|
|
|
return None
|
|
|
|
|
if parent.name in names:
|
|
|
|
|
return parent;
|
|
|
|
|
parent = parent.parent
|
|
|
|
|
parent = parent.parent
|
|
|
|
|
return parent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -181,7 +353,7 @@ def html_replace_tag(tag,str):
|
|
|
|
|
prev = newTag
|
|
|
|
|
else:
|
|
|
|
|
newTags = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isinstance(tag, soup.NavigableString)):
|
|
|
|
|
tag.extract()
|
|
|
|
|
else:
|
|
|
|
@ -193,14 +365,14 @@ def html_replace_tag(tag,str):
|
|
|
|
|
def html_shallow_search(starting_tag, names, filter = None):
|
|
|
|
|
if isinstance(starting_tag, soup.NavigableString):
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not utils.is_collection(names):
|
|
|
|
|
names = [ names ]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if starting_tag.name in names:
|
|
|
|
|
if filter is None or filter(starting_tag):
|
|
|
|
|
return [ starting_tag ]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
results = []
|
|
|
|
|
for tag in starting_tag.children:
|
|
|
|
|
if isinstance(tag, soup.NavigableString):
|
|
|
|
@ -218,7 +390,7 @@ def html_string_descendants(starting_tag, filter = None):
|
|
|
|
|
if isinstance(starting_tag, soup.NavigableString):
|
|
|
|
|
if filter is None or filter(starting_tag):
|
|
|
|
|
return [ starting_tag ]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
results = []
|
|
|
|
|
for tag in starting_tag.children:
|
|
|
|
|
if isinstance(tag, soup.NavigableString):
|
|
|
|
@ -258,16 +430,16 @@ class RegexReplacer(object):
|
|
|
|
|
self.__value = expression.sub(lambda m: self.__substitute(m), value)
|
|
|
|
|
if (not self.__result):
|
|
|
|
|
self.__groups = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return self.__value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __bool__(self):
|
|
|
|
|
return self.__result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __getitem__(self, key):
|
|
|
|
|
return self.__groups[key]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __len__(self):
|
|
|
|
|
return len(self.__groups)
|
|
|
|
|
|
|
|
|
@ -278,7 +450,7 @@ class RegexReplacer(object):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# allows the injection of custom tags using square-bracketed proxies.
|
|
|
|
|
class CustomTagsFix(object):
|
|
|
|
|
class CustomTagsFix(object):
|
|
|
|
|
__double_tags = re.compile(r"\[\s*(span|div|code|pre|h1|h2|h3|h4|h5|h6)(.*?)\s*\](.*?)\[\s*/\s*\1\s*\]", re.I)
|
|
|
|
|
__single_tags = re.compile(r"\[\s*(/?(?:span|div|code|pre|emoji|br|li|ul|ol))(\s.*?)?\s*\]", re.I)
|
|
|
|
|
__allowed_parents = ['dd', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li']
|
|
|
|
@ -318,13 +490,13 @@ class CustomTagsFix(object):
|
|
|
|
|
if emoji not in cls.__emojis:
|
|
|
|
|
return ''
|
|
|
|
|
return '&#x{}'.format(cls.__emojis[emoji][0])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
return '<{}{}>'.format(
|
|
|
|
|
m.group(1),
|
|
|
|
|
(' ' + str(m.group(2)).strip()) if m.group(2) else ''
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __call__(self, file, doc):
|
|
|
|
|
changed = False
|
|
|
|
|
for name in self.__allowed_parents:
|
|
|
|
@ -354,19 +526,19 @@ class CustomTagsFix(object):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# adds custom links to the navbar.
|
|
|
|
|
class NavBarFix(object):
|
|
|
|
|
|
|
|
|
|
__links = [
|
|
|
|
|
('Report an issue', 'https://github.com/marzer/tomlplusplus/issues'),
|
|
|
|
|
('Github', 'https://github.com/marzer/tomlplusplus/')
|
|
|
|
|
]
|
|
|
|
|
class NavBarFix(object):
|
|
|
|
|
|
|
|
|
|
def __call__(self, file, doc):
|
|
|
|
|
global repository
|
|
|
|
|
__links = [
|
|
|
|
|
('Report an issue', f'https://github.com/{repository}/issues'),
|
|
|
|
|
('Github', f'https://github.com/{repository}/')
|
|
|
|
|
]
|
|
|
|
|
list = doc.body.header.nav.div.div.select_one('#m-navbar-collapse').div.ol
|
|
|
|
|
if (list.select_one('.tpp-injected') is None):
|
|
|
|
|
if (list.select_one('.muu-injected') is None):
|
|
|
|
|
for label, url in self.__links:
|
|
|
|
|
doc.new_tag('a',
|
|
|
|
|
parent=doc.new_tag('li', parent=list, class_='tpp-injected tpp-external-navbar', index=0),
|
|
|
|
|
parent=doc.new_tag('li', parent=list, class_='muu-injected muu-external-navbar', index=0),
|
|
|
|
|
string=label,
|
|
|
|
|
href=url,
|
|
|
|
|
target='_blank'
|
|
|
|
@ -403,20 +575,20 @@ class ModifiersFixBase(object):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# fixes improperly-parsed modifiers on function signatures in the various 'detail view' sections.
|
|
|
|
|
class ModifiersFix1(ModifiersFixBase):
|
|
|
|
|
class ModifiersFix1(ModifiersFixBase):
|
|
|
|
|
|
|
|
|
|
__expression = re.compile(r'(\s+)({})(\s+)'.format(ModifiersFixBase._modifierRegex))
|
|
|
|
|
__sections = ['pub-static-methods', 'pub-methods', 'friends', 'func-members']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def __substitute(cls, m):
|
|
|
|
|
return '{}<span class="tpp-injected m-label m-flat {}">{}</span>{}'.format(
|
|
|
|
|
return '{}<span class="muu-injected m-label m-flat {}">{}</span>{}'.format(
|
|
|
|
|
m.group(1),
|
|
|
|
|
cls._modifierClasses[m.group(2)],
|
|
|
|
|
m.group(2),
|
|
|
|
|
m.group(3)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __call__(self, file, doc):
|
|
|
|
|
changed = False
|
|
|
|
|
for sect in self.__sections:
|
|
|
|
@ -435,7 +607,7 @@ class ModifiersFix1(ModifiersFixBase):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# fixes improperly-parsed modifiers on function signatures in the 'Function documentation' section.
|
|
|
|
|
class ModifiersFix2(ModifiersFixBase):
|
|
|
|
|
class ModifiersFix2(ModifiersFixBase):
|
|
|
|
|
|
|
|
|
|
__expression = re.compile(r'\s+({})\s+'.format(ModifiersFixBase._modifierRegex))
|
|
|
|
|
|
|
|
|
@ -443,7 +615,7 @@ class ModifiersFix2(ModifiersFixBase):
|
|
|
|
|
def __substitute(cls, m, matches):
|
|
|
|
|
matches.append(m.group(1))
|
|
|
|
|
return ' '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __call__(self, file, doc):
|
|
|
|
|
changed = False
|
|
|
|
|
sections = doc.find_all_from_sections(section=False) # all sections without an id
|
|
|
|
@ -469,7 +641,7 @@ class ModifiersFix2(ModifiersFixBase):
|
|
|
|
|
lastInserted = doc.new_tag('span',
|
|
|
|
|
parent=end,
|
|
|
|
|
string=match,
|
|
|
|
|
class_='tpp-injected m-label {}'.format(self._modifierClasses[match]),
|
|
|
|
|
class_='muu-injected m-label {}'.format(self._modifierClasses[match]),
|
|
|
|
|
before=lastInserted
|
|
|
|
|
)
|
|
|
|
|
lastInserted.insert_after(' ')
|
|
|
|
@ -482,56 +654,17 @@ class ModifiersFix2(ModifiersFixBase):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# applies some basic fixes to index.html
|
|
|
|
|
class IndexPageFix(object):
|
|
|
|
|
|
|
|
|
|
__badges = [
|
|
|
|
|
(
|
|
|
|
|
'Releases',
|
|
|
|
|
'https://img.shields.io/github/v/release/marzer/tomlplusplus?style=flat-square',
|
|
|
|
|
'https://github.com/marzer/tomlplusplus/releases'
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
'C++17',
|
|
|
|
|
'badge-C++17.svg',
|
|
|
|
|
'https://en.cppreference.com/w/cpp/compiler_support'
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
'C++20',
|
|
|
|
|
'badge-C++20.svg',
|
|
|
|
|
'https://en.cppreference.com/w/cpp/compiler_support'
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
'TOML v1.0.0-rc.1',
|
|
|
|
|
'badge-TOML.svg',
|
|
|
|
|
'https://toml.io/en/v1.0.0-rc.1'
|
|
|
|
|
),
|
|
|
|
|
(None, None, None), # <br>
|
|
|
|
|
(
|
|
|
|
|
'MIT License',
|
|
|
|
|
'badge-license-MIT.svg',
|
|
|
|
|
'https://github.com/marzer/tomlplusplus/blob/master/LICENSE'
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
'CircleCI',
|
|
|
|
|
'https://img.shields.io/circleci/build/github/marzer/tomlplusplus'
|
|
|
|
|
+ '?label=circle%20ci&logo=circleci&logoColor=white&style=flat-square',
|
|
|
|
|
'https://circleci.com/gh/marzer/tomlplusplus'
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
'Mentioned in Awesome C++',
|
|
|
|
|
'badge-awesome.svg',
|
|
|
|
|
'https://github.com/fffaraz/awesome-cpp'
|
|
|
|
|
)
|
|
|
|
|
]
|
|
|
|
|
class IndexPageFix(object):
|
|
|
|
|
|
|
|
|
|
def __call__(self, file, doc):
|
|
|
|
|
global badges
|
|
|
|
|
if file != 'index.html':
|
|
|
|
|
return False
|
|
|
|
|
parent = doc.body.main.article.div.div.div
|
|
|
|
|
banner = parent('img')[0].extract()
|
|
|
|
|
parent('h1')[0].replace_with(banner)
|
|
|
|
|
parent = doc.new_tag('div', class_='gh-badges', after=banner)
|
|
|
|
|
for (alt, src, href) in self.__badges:
|
|
|
|
|
for (alt, src, href) in badges:
|
|
|
|
|
if alt is None and src is None and href is None:
|
|
|
|
|
doc.new_tag('br', parent=parent)
|
|
|
|
|
else:
|
|
|
|
@ -570,13 +703,13 @@ class InlineNamespaceFix1(InlineNamespaceFixBase):
|
|
|
|
|
next = anchor.next_sibling
|
|
|
|
|
while (next is not None and isinstance(next, soup.NavigableString)):
|
|
|
|
|
next = next.next_sibling
|
|
|
|
|
if (next is not None and next.get('class') is not None and 'tpp-injected' in next.get('class')):
|
|
|
|
|
if (next is not None and next.get('class') is not None and 'muu-injected' in next.get('class')):
|
|
|
|
|
continue
|
|
|
|
|
doc.new_tag('span',
|
|
|
|
|
after=anchor,
|
|
|
|
|
string='inline',
|
|
|
|
|
title=inline_namespace_explainer,
|
|
|
|
|
class_='m-label m-info m-flat tpp-injected tpp-inline-namespace'
|
|
|
|
|
class_='m-label m-info m-flat muu-injected muu-inline-namespace'
|
|
|
|
|
)
|
|
|
|
|
anchor.insert_after(' ')
|
|
|
|
|
changed = True
|
|
|
|
@ -596,13 +729,13 @@ class InlineNamespaceFix2(InlineNamespaceFixBase):
|
|
|
|
|
changed = False
|
|
|
|
|
if (file in self._namespaceFiles):
|
|
|
|
|
h1 = doc.body.find('h1')
|
|
|
|
|
tag = h1.select_one('span.tpp-injected')
|
|
|
|
|
tag = h1.select_one('span.muu-injected')
|
|
|
|
|
if (tag is None):
|
|
|
|
|
tag = doc.new_tag('span',
|
|
|
|
|
parent=h1,
|
|
|
|
|
string='inline',
|
|
|
|
|
title=inline_namespace_explainer,
|
|
|
|
|
class_='m-label m-info tpp-injected tpp-inline-namespace'
|
|
|
|
|
class_='m-label m-info muu-injected muu-inline-namespace'
|
|
|
|
|
)
|
|
|
|
|
tag.insert_before(' ')
|
|
|
|
|
changed = True
|
|
|
|
@ -627,13 +760,13 @@ class InlineNamespaceFix3(InlineNamespaceFixBase):
|
|
|
|
|
next = anchor.next_sibling
|
|
|
|
|
while (next is not None and isinstance(next, soup.NavigableString)):
|
|
|
|
|
next = next.next_sibling
|
|
|
|
|
if (next is not None and next.get('class') is not None and 'tpp-injected' in next.get('class')):
|
|
|
|
|
if (next is not None and next.get('class') is not None and 'muu-injected' in next.get('class')):
|
|
|
|
|
continue
|
|
|
|
|
doc.new_tag('span',
|
|
|
|
|
after=anchor,
|
|
|
|
|
string='inline',
|
|
|
|
|
title=inline_namespace_explainer,
|
|
|
|
|
class_='m-label m-info m-flat tpp-injected tpp-inline-namespace'
|
|
|
|
|
class_='m-label m-info m-flat muu-injected muu-inline-namespace'
|
|
|
|
|
)
|
|
|
|
|
anchor.insert_after(' ')
|
|
|
|
|
changed = True
|
|
|
|
@ -668,7 +801,7 @@ class SyntaxHighlightingFix(object):
|
|
|
|
|
code_blocks = doc.body('pre', class_='m-code')
|
|
|
|
|
changed = False
|
|
|
|
|
for code_block in code_blocks:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# namespaces
|
|
|
|
|
names = code_block('span', class_='n')
|
|
|
|
|
names_ = []
|
|
|
|
@ -724,142 +857,22 @@ class SyntaxHighlightingFix(object):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# adds links to external sources where appropriate
|
|
|
|
|
class ExtDocLinksFix(object):
|
|
|
|
|
__types = [
|
|
|
|
|
(r'static_cast','https://en.cppreference.com/w/cpp/language/static_cast'),
|
|
|
|
|
(r'const_cast','https://en.cppreference.com/w/cpp/language/const_cast'),
|
|
|
|
|
(r'dynamic_cast','https://en.cppreference.com/w/cpp/language/dynamic_cast'),
|
|
|
|
|
(r'reinterpret_cast','https://en.cppreference.com/w/cpp/language/reinterpret_cast'),
|
|
|
|
|
(r'(?:std::)?size_t', 'https://en.cppreference.com/w/cpp/types/size_t'),
|
|
|
|
|
(r'(?:std::)?u?int(?:8|16|32|64)(fast|least)?_ts?', 'https://en.cppreference.com/w/cpp/types/integer'),
|
|
|
|
|
(r'std::pairs?', 'https://en.cppreference.com/w/cpp/utility/pair'),
|
|
|
|
|
(r'std::bytes?', 'https://en.cppreference.com/w/cpp/types/byte'),
|
|
|
|
|
(r'std::optionals?', 'https://en.cppreference.com/w/cpp/utility/optional'),
|
|
|
|
|
(r'std::tuples?', 'https://en.cppreference.com/w/cpp/utility/tuple'),
|
|
|
|
|
(r'std::integral_constants?', 'https://en.cppreference.com/w/cpp/types/integral_constant'),
|
|
|
|
|
(r'std::char_traits', 'https://en.cppreference.com/w/cpp/string/char_traits'),
|
|
|
|
|
(r'std::allocators?', 'https://en.cppreference.com/w/cpp/memory/allocator'),
|
|
|
|
|
(r'std::enable_if(?:_t)?', 'https://en.cppreference.com/w/cpp/types/enable_if'),
|
|
|
|
|
(r'std::conditional(?:_t)?', 'https://en.cppreference.com/w/cpp/types/conditional'),
|
|
|
|
|
(r'std::unordered_maps?', 'https://en.cppreference.com/w/cpp/container/unordered_map'),
|
|
|
|
|
(r'std::unordered_sets?', 'https://en.cppreference.com/w/cpp/container/unordered_set'),
|
|
|
|
|
(r'std::maps?', 'https://en.cppreference.com/w/cpp/container/map'),
|
|
|
|
|
(r'std::sets?', 'https://en.cppreference.com/w/cpp/container/set'),
|
|
|
|
|
(r'std::vectors?', 'https://en.cppreference.com/w/cpp/container/vector'),
|
|
|
|
|
(r'std::arrays?', 'https://en.cppreference.com/w/cpp/container/array'),
|
|
|
|
|
(r'std::chrono::durations?', 'https://en.cppreference.com/w/cpp/chrono/duration'),
|
|
|
|
|
(
|
|
|
|
|
r'std::atomic(?:_(?:'
|
|
|
|
|
+ r'bool|[su]?char(?:8_t|16_t|32_t)?|u?short'
|
|
|
|
|
+ r'|u?int(?:8_t|16_t|32_t|64_t)?|u?l?long'
|
|
|
|
|
+ r'))?',
|
|
|
|
|
'https://en.cppreference.com/w/cpp/atomic/atomic'
|
|
|
|
|
),
|
|
|
|
|
(r'std::unique_ptrs?', 'https://en.cppreference.com/w/cpp/memory/unique_ptr'),
|
|
|
|
|
(r'std::shared_ptrs?', 'https://en.cppreference.com/w/cpp/memory/shared_ptr'),
|
|
|
|
|
(r'(?:std::)?nullptr_t', 'https://en.cppreference.com/w/cpp/types/nullptr_t'),
|
|
|
|
|
(r'std::reverse_iterator', 'https://en.cppreference.com/w/cpp/iterator/reverse_iterator'),
|
|
|
|
|
(r'std::(?:basic_|w)?istreams?', 'https://en.cppreference.com/w/cpp/io/basic_istream'),
|
|
|
|
|
(r'std::(?:basic_|w)?ostreams?', 'https://en.cppreference.com/w/cpp/io/basic_ostream'),
|
|
|
|
|
(r'std::(?:basic_|w)?iostreams?', 'https://en.cppreference.com/w/cpp/io/basic_iostream'),
|
|
|
|
|
(r'std::(?:basic_|w)?ifstreams?', 'https://en.cppreference.com/w/cpp/io/basic_ifstream'),
|
|
|
|
|
(r'std::(?:basic_|w)?ofstreams?', 'https://en.cppreference.com/w/cpp/io/basic_ofstream'),
|
|
|
|
|
(r'std::(?:basic_|w)?fstreams?', 'https://en.cppreference.com/w/cpp/io/basic_fstream'),
|
|
|
|
|
(r'std::(?:basic_|w)?istringstreams?', 'https://en.cppreference.com/w/cpp/io/basic_istringstream'),
|
|
|
|
|
(r'std::(?:basic_|w)?ostringstreams?', 'https://en.cppreference.com/w/cpp/io/basic_ostringstream'),
|
|
|
|
|
(r'std::(?:basic_|w)?stringstreams?', 'https://en.cppreference.com/w/cpp/io/basic_stringstream'),
|
|
|
|
|
(r'std::(?:basic_|w|u8)?string_views?', 'https://en.cppreference.com/w/cpp/string/basic_string_view'),
|
|
|
|
|
(r'std::(?:basic_|w|u8)?strings?', 'https://en.cppreference.com/w/cpp/string/basic_string'),
|
|
|
|
|
(r'\s(?:<|<)fstream(?:>|>)', 'https://en.cppreference.com/w/cpp/header/fstream'),
|
|
|
|
|
(r'\s(?:<|<)sstream(?:>|>)', 'https://en.cppreference.com/w/cpp/header/sstream'),
|
|
|
|
|
(r'\s(?:<|<)iostream(?:>|>)', 'https://en.cppreference.com/w/cpp/header/iostream'),
|
|
|
|
|
(r'\s(?:<|<)iosfwd(?:>|>)', 'https://en.cppreference.com/w/cpp/header/iosfwd'),
|
|
|
|
|
(r'\s(?:<|<)string(?:>|>)', 'https://en.cppreference.com/w/cpp/header/string'),
|
|
|
|
|
(r'\s(?:<|<)string_view(?:>|>)', 'https://en.cppreference.com/w/cpp/header/string_view'),
|
|
|
|
|
(r'char(?:8|16|32)_ts?', 'https://en.cppreference.com/w/cpp/language/types'),
|
|
|
|
|
(r'std::is_(?:nothrow_)?convertible(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_convertible'),
|
|
|
|
|
(r'std::is_same(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_same'),
|
|
|
|
|
(r'std::is_base_of(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_base_of'),
|
|
|
|
|
(r'std::is_enum(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_enum'),
|
|
|
|
|
(r'std::is_floating_point(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_floating_point'),
|
|
|
|
|
(r'std::is_integral(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_integral'),
|
|
|
|
|
(r'std::is_pointer(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_pointer'),
|
|
|
|
|
(r'std::is_reference(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_reference'),
|
|
|
|
|
(r'std::is_signed(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_signed'),
|
|
|
|
|
(r'std::is_unsigned(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_unsigned'),
|
|
|
|
|
(r'std::is_void(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_void'),
|
|
|
|
|
(r'std::is_(?:nothrow_)?invocable(?:_r)?', 'https://en.cppreference.com/w/cpp/types/is_invocable'),
|
|
|
|
|
(r'std::add_[lr]value_reference(?:_t)?', 'https://en.cppreference.com/w/cpp/types/add_reference'),
|
|
|
|
|
(r'std::remove_reference(?:_t)?', 'https://en.cppreference.com/w/cpp/types/remove_reference'),
|
|
|
|
|
(r'std::remove_cv(?:_t)?', 'https://en.cppreference.com/w/cpp/types/remove_cv'),
|
|
|
|
|
(r'std::underlying_type(?:_t)?', 'https://en.cppreference.com/w/cpp/types/underlying_type'),
|
|
|
|
|
(r'std::exceptions?', 'https://en.cppreference.com/w/cpp/error/exception'),
|
|
|
|
|
(r'std::runtime_errors?', 'https://en.cppreference.com/w/cpp/error/runtime_error'),
|
|
|
|
|
(r'std::is_constant_evaluated', 'https://en.cppreference.com/w/cpp/types/is_constant_evaluated'),
|
|
|
|
|
(r'std::launder', 'https://en.cppreference.com/w/cpp/utility/launder'),
|
|
|
|
|
(r'std::bit_width', 'https://en.cppreference.com/w/cpp/numeric/bit_width'),
|
|
|
|
|
(r'std::bit_ceil', 'https://en.cppreference.com/w/cpp/numeric/bit_ceil'),
|
|
|
|
|
(r'std::bit_floor', 'https://en.cppreference.com/w/cpp/numeric/bit_floor'),
|
|
|
|
|
(r'std::bit_cast', 'https://en.cppreference.com/w/cpp/numeric/bit_cast'),
|
|
|
|
|
(r'std::countl_zero', 'https://en.cppreference.com/w/cpp/numeric/countl_zero'),
|
|
|
|
|
(r'std::countr_zero', 'https://en.cppreference.com/w/cpp/numeric/countr_zero'),
|
|
|
|
|
(r'std::countl_one', 'https://en.cppreference.com/w/cpp/numeric/countl_one'),
|
|
|
|
|
(r'std::countr_one', 'https://en.cppreference.com/w/cpp/numeric/countr_one'),
|
|
|
|
|
(r'std::popcount', 'https://en.cppreference.com/w/cpp/numeric/popcount'),
|
|
|
|
|
(r'std::has_single_bit', 'https://en.cppreference.com/w/cpp/numeric/has_single_bit'),
|
|
|
|
|
(r'std::min', 'https://en.cppreference.com/w/cpp/algorithm/min'),
|
|
|
|
|
(r'std::max', 'https://en.cppreference.com/w/cpp/algorithm/max'),
|
|
|
|
|
(r'std::clamp', 'https://en.cppreference.com/w/cpp/algorithm/clamp'),
|
|
|
|
|
(r'std::numeric_limits', 'https://en.cppreference.com/w/cpp/types/numeric_limits'),
|
|
|
|
|
(r'std::initializer_lists?', 'https://en.cppreference.com/w/cpp/utility/initializer_list'),
|
|
|
|
|
(
|
|
|
|
|
r'(?:L?P)?(?:'
|
|
|
|
|
+ r'D?WORD(?:32|64|_PTR)?|HANDLE|HMODULE|BOOL(?:EAN)?'
|
|
|
|
|
+ r'|U?SHORT|U?LONG|U?INT(?:8|16|32|64)?'
|
|
|
|
|
+ r'|BYTE|VOID|C[WT]?STR'
|
|
|
|
|
+ r')',
|
|
|
|
|
'https://docs.microsoft.com/en-us/windows/desktop/winprog/windows-data-types'
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
r'(?:__INTELLISENSE__|_MSC_FULL_VER|_MSC_VER|_MSVC_LANG|_WIN32|_WIN64)',
|
|
|
|
|
'https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2019'
|
|
|
|
|
),
|
|
|
|
|
(r'IUnknowns?', 'https://docs.microsoft.com/en-us/windows/win32/api/unknwn/nn-unknwn-iunknown'),
|
|
|
|
|
(r'(?:IUnknown::)?QueryInterface?', 'https://docs.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-queryinterface(q)'),
|
|
|
|
|
(r'(?:Legacy)?InputIterators?', 'https://en.cppreference.com/w/cpp/named_req/InputIterator'),
|
|
|
|
|
(r'(?:Legacy)?OutputIterators?', 'https://en.cppreference.com/w/cpp/named_req/OutputIterator'),
|
|
|
|
|
(r'(?:Legacy)?ForwardIterators?', 'https://en.cppreference.com/w/cpp/named_req/ForwardIterator'),
|
|
|
|
|
(r'(?:Legacy)?BidirectionalIterators?', 'https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator'),
|
|
|
|
|
(r'(?:Legacy)?RandomAccessIterators?', 'https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator'),
|
|
|
|
|
(r'(?:Legacy)?ContiguousIterators?', 'https://en.cppreference.com/w/cpp/named_req/ContiguousIterator'),
|
|
|
|
|
(
|
|
|
|
|
r'(?:'
|
|
|
|
|
+ r'__cplusplus|__STDC_HOSTED__'
|
|
|
|
|
+ r'|__FILE__|__LINE__'
|
|
|
|
|
+ r'|__DATE__|__TIME__'
|
|
|
|
|
+ r'|__STDCPP_DEFAULT_NEW_ALIGNMENT__'
|
|
|
|
|
+ r')',
|
|
|
|
|
'https://en.cppreference.com/w/cpp/preprocessor/replace'
|
|
|
|
|
),
|
|
|
|
|
# toml-specific
|
|
|
|
|
(r'toml::values?', 'classtoml_1_1value.html'),
|
|
|
|
|
(r'(toml::)?date_times?', 'structtoml_1_1date__time.html'),
|
|
|
|
|
(r'(toml::)?time', 'structtoml_1_1time.html'),
|
|
|
|
|
(r'(toml::)?dates?', 'structtoml_1_1date.html')
|
|
|
|
|
]
|
|
|
|
|
class ExtDocLinksFix(object):
|
|
|
|
|
|
|
|
|
|
__allowedNames = ['dd', 'p', 'dt', 'h3', 'td', 'div']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
global external_links
|
|
|
|
|
self.__expressions = []
|
|
|
|
|
for type, uri in self.__types:
|
|
|
|
|
for type, uri in external_links:
|
|
|
|
|
self.__expressions.append((re.compile('(?<![a-zA-Z_])'+type+'(?![a-zA-Z_])'), uri))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def __substitute(cls, m, uri):
|
|
|
|
|
external = uri.startswith('http')
|
|
|
|
|
return r'<a href="{}" class="m-doc tpp-injected{}"{}>{}</a>'.format(
|
|
|
|
|
return r'<a href="{}" class="m-doc muu-injected{}"{}>{}</a>'.format(
|
|
|
|
|
uri,
|
|
|
|
|
' tpp-external' if external else '',
|
|
|
|
|
' muu-external' if external else '',
|
|
|
|
|
' target="_blank"' if external else '',
|
|
|
|
|
m.group(0),
|
|
|
|
|
)
|
|
|
|
@ -867,10 +880,10 @@ class ExtDocLinksFix(object):
|
|
|
|
|
def __call__(self, file, doc):
|
|
|
|
|
changed = False
|
|
|
|
|
root = doc.body.main.article.div.div
|
|
|
|
|
tags = tags = html_shallow_search(root, self.__allowedNames, lambda t: html_find_parent(t, 'a', root) is None)
|
|
|
|
|
tags = html_shallow_search(root, self.__allowedNames, lambda t: html_find_parent(t, 'a', root) is None)
|
|
|
|
|
strings = []
|
|
|
|
|
for tag in tags:
|
|
|
|
|
strings = strings + html_string_descendants(tag, lambda t: html_find_parent(t, 'a', tag) is None)
|
|
|
|
|
strings = strings + html_string_descendants(tag, lambda t: html_find_parent(t, 'a', tag) is None)
|
|
|
|
|
for expr, uri in self.__expressions:
|
|
|
|
|
for string in strings:
|
|
|
|
|
if string.parent is None:
|
|
|
|
@ -905,21 +918,21 @@ class EnableIfFix(object):
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
__spacingFix1 = re.compile(r'(_v|>::value)(&&|\|\|)')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def __substitute(cls, m):
|
|
|
|
|
return r'{}<span class="tpp-injected tpp-enable-if"><a href="#" onclick="ToggleEnableIf(this);return false;">...</a><span>{}</span></span>{}'.format(
|
|
|
|
|
return r'{}<span class="muu-injected muu-enable-if"><a href="#" onclick="ToggleEnableIf(this);return false;">...</a><span>{}</span></span>{}'.format(
|
|
|
|
|
m.group(1),
|
|
|
|
|
m.group(2),
|
|
|
|
|
m.group(3)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __call__(self, file, doc):
|
|
|
|
|
changed = False
|
|
|
|
|
for template in doc.body('div', class_='m-doc-template'):
|
|
|
|
|
replacer = RegexReplacer(self.__expression, lambda m: self.__substitute(m), str(template))
|
|
|
|
|
if replacer:
|
|
|
|
|
injected = html_replace_tag(template, str(replacer))[0].select_one(".tpp-enable-if")
|
|
|
|
|
injected = html_replace_tag(template, str(replacer))[0].select_one(".muu-enable-if")
|
|
|
|
|
anchor = injected.a
|
|
|
|
|
content = injected.span
|
|
|
|
|
tweaks = []
|
|
|
|
@ -954,7 +967,7 @@ class ExternalLinksFix(object):
|
|
|
|
|
if 'target' not in anchor.attrs or anchor['target'] != '_blank':
|
|
|
|
|
anchor['target'] = '_blank'
|
|
|
|
|
changed = True
|
|
|
|
|
changed = html_append_class(anchor, 'tpp-external') or changed
|
|
|
|
|
changed = html_append_class(anchor, 'muu-external') or changed
|
|
|
|
|
|
|
|
|
|
# do magic with godbolt.org links
|
|
|
|
|
if self.__godbolt.fullmatch(anchor['href']):
|
|
|
|
@ -975,6 +988,46 @@ class ExternalLinksFix(object):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# overrides <path/to/header.h> links
|
|
|
|
|
class HeaderOverridesFix(object):
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
global header_overrides
|
|
|
|
|
self.__expressions = []
|
|
|
|
|
for header, repl, html_file in header_overrides:
|
|
|
|
|
self.__expressions.append((
|
|
|
|
|
re.compile('(?:<|")'+header+'(?:>|")'),
|
|
|
|
|
'<' + repl + '>',
|
|
|
|
|
html_file
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def __substitute(cls, m, repl):
|
|
|
|
|
return repl
|
|
|
|
|
|
|
|
|
|
def __call__(self, file, doc):
|
|
|
|
|
changed = False
|
|
|
|
|
root = doc.body.main.article.div.div
|
|
|
|
|
tags = root.find_all('a', string=True)
|
|
|
|
|
for tag in tags:
|
|
|
|
|
skip = False
|
|
|
|
|
for expr, repl, html_file in self.__expressions:
|
|
|
|
|
replacer = RegexReplacer(expr, lambda m: self.__substitute(m, repl), tag.string)
|
|
|
|
|
if replacer:
|
|
|
|
|
tag.string = str(replacer)
|
|
|
|
|
tag["href"] = html_file
|
|
|
|
|
changed = True
|
|
|
|
|
skip = True
|
|
|
|
|
if skip:
|
|
|
|
|
continue
|
|
|
|
|
return changed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#=======================================================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_threadError = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1018,7 +1071,7 @@ def preprocess_xml(xml_dir):
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
global _threadError
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
num_threads = os.cpu_count() * 2
|
|
|
|
|
root_dir = path.join(utils.get_script_folder(), '..')
|
|
|
|
|
docs_dir = path.join(root_dir, 'docs')
|
|
|
|
@ -1042,7 +1095,7 @@ def main():
|
|
|
|
|
|
|
|
|
|
# delete xml
|
|
|
|
|
utils.delete_directory(xml_dir)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# post-process html files
|
|
|
|
|
fixes = [
|
|
|
|
|
CustomTagsFix()
|
|
|
|
@ -1057,6 +1110,7 @@ def main():
|
|
|
|
|
, ExtDocLinksFix()
|
|
|
|
|
, EnableIfFix()
|
|
|
|
|
, ExternalLinksFix()
|
|
|
|
|
, HeaderOverridesFix()
|
|
|
|
|
]
|
|
|
|
|
files = [path.split(f) for f in utils.get_all_files(html_dir, any=('*.html', '*.htm'))]
|
|
|
|
|
if files:
|
|
|
|
|