Skip to content

Commit

Permalink
Simplify the handling of the recipes' extra details
Browse files Browse the repository at this point in the history
There is no need to keep them in data['objects']

Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
  • Loading branch information
martin-g committed Nov 28, 2024
1 parent e8ceb5c commit eda8dec
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions source/_ext/bioconda_sphinx_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
import logging
logger = logging.getLogger(__name__) # pylint: disable=invalid-name

recipe_additional_platforms = {};
# A structure that holds extra information about recipes
recipes_details = {}

def as_extlink_filter(text):
"""Jinja2 filter converting identifier (list) to extlink format
Expand Down Expand Up @@ -332,7 +333,7 @@ def add_target_and_index(self, name: str, sig: str,
"Duplicate entry {} {} at {} (other in {})".format(
self.objtype, name, self.lineno,
self.env.doc2path(objects[key][0])))
objects[key] = (self.env.docname, target_name, recipe_additional_platforms[name])
objects[key] = (self.env.docname, target_name)

index_text = self.get_index_text(name)
if index_text:
Expand Down Expand Up @@ -397,10 +398,11 @@ def generate(self, docnames: Optional[List[str]] = None):
content = []

objects = sorted(self.domain.data['objects'].items())
for (typ, name), (docname, labelid, description) in objects:
for (typ, name), (docname, labelid) in objects:
if docnames and docname not in docnames:
continue

description = recipes_details[name]
# TODO: Add meaningful info for extra/qualifier/description
# fields, e.g., latest package version.
content.append({
Expand Down Expand Up @@ -443,7 +445,7 @@ def clear_doc(self, docname: str):
if 'objects' not in self.data:
return
to_remove = [
key for (key, (stored_docname, _, _)) in self.data['objects'].items()
key for (key, (stored_docname, _)) in self.data['objects'].items()
if docname == stored_docname
]
for key in to_remove:
Expand Down Expand Up @@ -497,17 +499,17 @@ def get_objects(self):
- 2: object is unimportant (placed after full-text matches)
- -1: object should not show up in search at all
"""
for (typ, name), (docname, ref, _) in self.data['objects'].items():
for (typ, name), (docname, ref) in self.data['objects'].items():
dispname = "{} '{}'".format(typ, name)
yield name, dispname, typ, docname, ref, 1

def merge_domaindata(self, docnames: List[str], otherdata: Dict) -> None:
"""Merge in data regarding *docnames* from a different domaindata
inventory (coming from a subprocess in parallel builds).
"""
for (typ, name), (docname, ref, description) in otherdata['objects'].items():
for (typ, name), (docname, ref) in otherdata['objects'].items():
if docname in docnames:
self.data['objects'][typ, name] = (docname, ref, description)
self.data['objects'][typ, name] = (docname, ref)
# broken?
#for key, data in otherdata['backrefs'].items():
# if docname in docnames:
Expand Down Expand Up @@ -609,9 +611,9 @@ def generate_readme(recipe_basedir, output_dir, folder, repodata, renderer):
}

if recipe_extra is None:
recipe_additional_platforms[recipe.name] = ''
recipes_details[recipe.name] = ''
else:
recipe_additional_platforms[recipe.name] = ', '.join(recipe_extra.get('additional-platforms', []))
recipes_details[recipe.name] = ', '.join(recipe_extra.get('additional-platforms', []))

renderer.render_to_file(output_file, 'readme.rst_t', template_options)
return [output_file]
Expand Down

0 comments on commit eda8dec

Please sign in to comment.