Skip to content

Commit

Permalink
added empty tag prune step
Browse files Browse the repository at this point in the history
also:
- added `NDEBUG` to default set of defines
  • Loading branch information
marzer committed Apr 26, 2021
1 parent bc67a66 commit e616234
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# poxy
Documentation generator for C++ based on Doxygen and [mosra/m.css](https://mcss.mosra.cz/).

```
pip install poxy
```
20 changes: 18 additions & 2 deletions poxy/fixers.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ class Links(object):

def __call__(self, doc, context):
changed = False
for anchor in doc.body('a', recursive=True, href=True):
for anchor in doc.body('a', href=True):
href = anchor['href']

# make sure links to external sources are correctly marked as such
Expand Down Expand Up @@ -680,7 +680,7 @@ def __call__(self, doc, context):
# make sure internal documentation #id links actually have somewhere to go
if (is_mdoc
and href.startswith(r'#')
and (len(href) == 1 or doc.body.find(id=href[1:], recursive=True) is None)):
and (len(href) == 1 or doc.body.find(id=href[1:]) is None)):
changed = True
soup.remove_class(anchor, 'm-doc')
soup.add_class(anchor, 'm-doc-self')
Expand All @@ -697,3 +697,19 @@ def __call__(self, doc, context):
continue

return changed

#=======================================================================================================================
# empty tags
#=======================================================================================================================

class EmptyTags(object):
'''
Prunes the tree of various empty tags (happens as a side-effect of some other operations).
'''
def __call__(self, doc, context):
changed = False
for tag in doc.body((r'p', r'span')):
if not tag.contents or (len(tag.contents) == 1 and isinstance(tag.contents[0], soup.NavigableString) and not tag.string):
soup.destroy_node(tag)
changed = True
return changed
1 change: 1 addition & 0 deletions poxy/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class _Defaults(object):
r'[Mm]at(?:rix)?[1-4](?:[xX][1-4])?[hifd]?'
}
defines = {
r'NDEBUG' : 1,
r'DOXYGEN' : 1,
r'__DOXYGEN__' : 1,
r'__doxygen__' : 1,
Expand Down
3 changes: 2 additions & 1 deletion poxy/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ def _postprocess_html_file(path, context=None):
if fix(doc, context):
doc.smooth()
changed = True
if (changed):
if changed:
doc.flush()
return changed

Expand All @@ -743,6 +743,7 @@ def _postprocess_html(context):
, fixers.AutoDocLinks()
, fixers.Links()
, fixers.CustomTags()
, fixers.EmptyTags()
)
context.verbose(rf'Post-processing {len(files)} HTML files...')
if threads > 1:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def enum_subdirs(root):

setup_args = dict(
name=r'poxy',
version=r'0.1.0',
version=r'0.1.1',
description=r'Documentation generator for C++.',
long_description_content_type=r'text/markdown',
long_description=f'{README}\n\n{HISTORY}'.strip(),
Expand Down

0 comments on commit e616234

Please sign in to comment.