Add support for skipping private headlines.
This commit is contained in:
parent
06b5d1b50c
commit
a00a53612e
2 changed files with 39 additions and 2 deletions
|
@ -123,6 +123,21 @@ def load_all(top_dir_relative):
|
|||
logging.info("Collected {} files".format(len(docs)))
|
||||
return docs
|
||||
|
||||
def remove_non_public_headlines(doc: org_rw.OrgDoc | org_rw.Headline):
|
||||
if isinstance(doc, org_rw.OrgDoc):
|
||||
doc.headlines = list(filter_private_headlines(doc.headlines))
|
||||
for hl in doc.headlines:
|
||||
remove_non_public_headlines(hl)
|
||||
else:
|
||||
doc.children = list(filter_private_headlines(doc.children))
|
||||
for hl in doc.children:
|
||||
remove_non_public_headlines(hl)
|
||||
|
||||
def filter_private_headlines(headlines):
|
||||
for hl in headlines:
|
||||
if 'private' not in hl.tags:
|
||||
yield hl
|
||||
|
||||
def regen_all(src_top, dest_top, subpath, *, docs=None, db=None):
|
||||
files_generated = 0
|
||||
cur = db.cursor()
|
||||
|
@ -150,6 +165,8 @@ def regen_all(src_top, dest_top, subpath, *, docs=None, db=None):
|
|||
main_headline_to_docid = {}
|
||||
for doc in docs:
|
||||
relpath = os.path.relpath(doc.path, src_top)
|
||||
|
||||
remove_non_public_headlines(doc)
|
||||
changed = False
|
||||
headlines = list(doc.getAllHeadlines())
|
||||
related = None
|
||||
|
@ -717,8 +734,11 @@ def render_connections(headline_id, content, graph, doc_to_headline_remapping):
|
|||
# return
|
||||
|
||||
logging.info("Generating centered graph for {}".format(headline_id))
|
||||
svg = gen_centered_graph.gen(headline_id, graph['nodes'], doc_to_headline_remapping)
|
||||
content.append("<div class='connections'>{}</div>".format(svg))
|
||||
try:
|
||||
svg = gen_centered_graph.gen(headline_id, graph['nodes'], doc_to_headline_remapping)
|
||||
content.append("<div class='connections'>{}</div>".format(svg))
|
||||
except:
|
||||
logging.warning("Broken reference on headline ID={}".format(headline_id))
|
||||
|
||||
def render(headline, doc, graph, headlineLevel, doc_to_headline_remapping):
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue