Skip to content

Commit b87a3d6

Browse files
committed
Enhance tools functionality in Boost library
- Added a new tool "boostlook" to the TOOLS constant in constants.py with its description and URL. - Modified the get_tools function in utils.py to accept an optional version parameter, allowing for dynamic URL generation for version-specific tools. - Updated LibraryListBase and LibraryCategorized views to pass the selected version to get_tools, ensuring correct URL handling in the context data.
1 parent 11078b2 commit b87a3d6

3 files changed

Lines changed: 46 additions & 18 deletions

File tree

libraries/constants.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -370,46 +370,54 @@
370370

371371
RELEASE_REPORT_AUTHORS_PER_PAGE_THRESHOLD = 6
372372
TOOLS = [
373+
{
374+
"name": "boostlook",
375+
"description": "A CSS framework for Boost C++ Library documentation.",
376+
"url_path": "https://github.com/boostorg/boostlook",
377+
"version_specific": False,
378+
},
373379
{
374380
"name": "Boost.Build",
375381
"slug": "build",
376382
"description": "The Boost build system, including the full Boost version of the jam sources.",
377-
"url": "libs/latest/tools/build/doc/html/index.html",
383+
"version_specific": True,
384+
"url_path": "tools/build/doc/html/index.html",
378385
},
379386
{
380387
"name": "Regression",
381-
"slug": "regression",
382388
"description": "The Boost regression testing system reporting sources.",
383-
"url": "tools/regression/index.html",
389+
"url_path": "https://www.boost.org/doc/contributor-guide/testing/regression-tests.html",
390+
"version_specific": False,
384391
},
385392
{
386393
"name": "Inspect",
387-
"slug": "inspect",
388394
"description": "The inspection tool used to detect errors in the Boost directory hierarchy.",
389-
"url": "tools/inspect/index.html",
395+
"version_specific": True,
396+
"url_path": "tools/inspect/index.html",
390397
},
391398
{
392399
"name": "BoostBook",
393-
"slug": "boostbook",
394400
"description": "A Boost documentation system, based on DocBook and the Extensible Stylesheet Language (XSL), used by some Boost libraries.",
395-
"url": "tools/boostbook/index.html",
401+
"version_specific": True,
402+
"url_path": "tools/boostbook/index.html",
396403
},
397404
{
398405
"name": "bcp",
399-
"slug": "bcp",
400406
"description": "A utility to extract subsets of Boost; to determine which parts of Boost your code is using; and to print reports on Boost usage (including Licence information).",
401-
"url": "tools/bcp/",
407+
"version_specific": True,
408+
"url_path": "tools/bcp/",
402409
},
403410
{
404411
"name": "QuickBook",
405-
"slug": "quickbook",
406412
"description": "QuickBook is a WikiWiki style documentation tool geared towards C++ documentation using simple rules and markup for simple formatting tasks. QuickBook generates BoostBook XML.",
407-
"url": "",
413+
"url_path": "https://www.boost.org/doc/libs/latest/doc/html/quickbook.html",
414+
"version_specific": False,
408415
},
409416
{
410417
"name": "Wave",
411418
"slug": "wave",
412419
"description": "A Standards conformant C/C++ preprocessor usable on top of any other compiler. Usable for instance for the debugging of the expansion of macros in your code or as a replacement for your built-in preprocessor.",
413-
"url": "",
420+
"version_specific": True,
421+
"url_path": "libs/wave/index.html",
414422
},
415423
]

libraries/utils.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,19 +373,39 @@ def generate_release_report_filename(version_slug: str, published_format: bool =
373373
return filename
374374

375375

376-
def get_tools():
376+
def get_tools(version=None):
377377
"""
378378
Return list of tool dictionaries.
379379
380380
Tools are utilities used by Boost developers and users,
381381
separate from libraries. They appear alongside libraries
382382
in library list views.
383383
384+
Args:
385+
version: Optional Version object. If provided, tools with
386+
version_specific=True will have their URLs generated
387+
based on the version.
388+
384389
Returns:
385390
list: List of tool dictionaries with keys:
386391
- name: str
387-
- slug: str
388392
- description: str
389-
- url: str
393+
- url: str (generated for version_specific tools if version provided)
390394
"""
391-
return sorted(TOOLS.copy(), key=lambda tool: tool["name"].lower())
395+
tools = []
396+
for tool in TOOLS.copy():
397+
tool_dict = tool.copy()
398+
url_path = tool_dict.get("url_path", "")
399+
if tool_dict.get("version_specific"):
400+
if version:
401+
version_slug = version.stripped_boost_url_slug
402+
tool_dict["url"] = (
403+
f"https://www.boost.org/doc/libs/{version_slug}/{url_path}"
404+
)
405+
else:
406+
tool_dict["url"] = ""
407+
else:
408+
# For non-version-specific tools, use url_path as-is (full URL)
409+
tool_dict["url"] = url_path
410+
tools.append(tool_dict)
411+
return sorted(tools, key=lambda tool: tool["name"].lower())

libraries/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def get_queryset(self):
105105
def get_context_data(self, **kwargs):
106106
context = super().get_context_data(**self.kwargs)
107107
context["categories"] = self.get_categories(context["selected_version"])
108-
context["tools"] = get_tools()
108+
context["tools"] = get_tools(version=context.get("selected_version"))
109109
# todo: add tests for sort order
110110
if self.kwargs.get("category_slug"):
111111
context["category"] = Category.objects.get(
@@ -214,7 +214,7 @@ def get_results_by_category(self, version: Version | None):
214214
)
215215

216216
# Add tools as a separate category
217-
tools = get_tools()
217+
tools = get_tools(version=version)
218218
if tools:
219219
# Create a simple object for tools category
220220
class ToolsCategory:

0 commit comments

Comments
 (0)