-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
manifest: move optional modules to a submanifest and make them optional #61505
Changes from 1 commit
dbdeb47
bbe5f69
c4d3b89
1e9a6ad
0701de7
e534d96
902dfee
84858a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,141 @@ | ||||||
""" | ||||||
Manifest Revisions Table | ||||||
======================== | ||||||
|
||||||
This extension allows to render a table containing the revisions of the projects | ||||||
present in a manifest file. | ||||||
|
||||||
Usage | ||||||
***** | ||||||
|
||||||
This extension introduces a new directive: ``manifest-projects-table``. It can | ||||||
be used in the code as:: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
.. manifest-projects-table:: | ||||||
:filter: active | ||||||
|
||||||
where the ``:filter:`` option can have the following values: active, inactive, all. | ||||||
|
||||||
Options | ||||||
******* | ||||||
|
||||||
- ``manifest_projects_table_manifest``: Path to the manifest file. | ||||||
|
||||||
Copyright (c) Nordic Semiconductor ASA 2022 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To keep divergence somewhat under control can you please add the "upstream" URL where this came from? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no intention to keep this compatible or in sync with "upstream" |
||||||
Copyright (c) Intel Corp 2023 | ||||||
SPDX-License-Identifier: Apache-2.0 | ||||||
""" | ||||||
|
||||||
import re | ||||||
from typing import Any, Dict, List | ||||||
|
||||||
from docutils import nodes | ||||||
from docutils.parsers.rst import directives | ||||||
from sphinx.application import Sphinx | ||||||
from sphinx.util.docutils import SphinxDirective | ||||||
from west.manifest import Manifest | ||||||
|
||||||
|
||||||
__version__ = "0.1.0" | ||||||
|
||||||
|
||||||
class ManifestProjectsTable(SphinxDirective): | ||||||
"""Manifest revisions table.""" | ||||||
|
||||||
option_spec = { | ||||||
"filter": directives.unchanged, | ||||||
} | ||||||
|
||||||
@staticmethod | ||||||
def rev_url(base_url: str, rev: str) -> str: | ||||||
"""Return URL for a revision. | ||||||
|
||||||
Notes: | ||||||
Revision format is assumed to be a git hash or a tag. URL is | ||||||
formatted assuming a GitHub base URL. | ||||||
|
||||||
Args: | ||||||
base_url: Base URL of the repository. | ||||||
rev: Revision. | ||||||
|
||||||
Returns: | ||||||
URL for the revision. | ||||||
""" | ||||||
|
||||||
if re.match(r"^[0-9a-f]{40}$", rev): | ||||||
return f"{base_url}/commit/{rev}" | ||||||
|
||||||
return f"{base_url}/releases/tag/{rev}" | ||||||
|
||||||
def run(self) -> List[nodes.Element]: | ||||||
active_filter = self.options.get("filter", None) | ||||||
|
||||||
manifest = Manifest.from_file(self.env.config.manifest_projects_table_manifest) | ||||||
projects = [] | ||||||
for project in manifest.projects: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are the odds of eventually adding more optional metadata to the Project? Would be nice for this table to include the link to the docs for the module if available. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a more detailed description field was already added, we probably want to add more, I agree. |
||||||
if project.name == "manifest": | ||||||
continue | ||||||
if active_filter == 'active' and manifest.is_active(project): | ||||||
projects.append(project) | ||||||
elif active_filter == 'inactive' and not manifest.is_active(project): | ||||||
projects.append(project) | ||||||
elif active_filter == 'all' or active_filter is None: | ||||||
projects.append(project) | ||||||
|
||||||
# build table | ||||||
table = nodes.table() | ||||||
|
||||||
tgroup = nodes.tgroup(cols=2) | ||||||
tgroup += nodes.colspec(colwidth=1) | ||||||
tgroup += nodes.colspec(colwidth=1) | ||||||
table += tgroup | ||||||
|
||||||
thead = nodes.thead() | ||||||
tgroup += thead | ||||||
|
||||||
row = nodes.row() | ||||||
thead.append(row) | ||||||
|
||||||
entry = nodes.entry() | ||||||
entry += nodes.paragraph(text="Project") | ||||||
row += entry | ||||||
entry = nodes.entry() | ||||||
entry += nodes.paragraph(text="Revision") | ||||||
row += entry | ||||||
|
||||||
rows = [] | ||||||
for project in projects: | ||||||
row = nodes.row() | ||||||
rows.append(row) | ||||||
|
||||||
entry = nodes.entry() | ||||||
entry += nodes.paragraph(text=project.name) | ||||||
row += entry | ||||||
entry = nodes.entry() | ||||||
par = nodes.paragraph() | ||||||
par += nodes.reference( | ||||||
project.revision, | ||||||
project.revision, | ||||||
internal=False, | ||||||
refuri=ManifestProjectsTable.rev_url(project.url, project.revision), | ||||||
) | ||||||
entry += par | ||||||
row += entry | ||||||
|
||||||
tbody = nodes.tbody() | ||||||
tbody.extend(rows) | ||||||
tgroup += tbody | ||||||
|
||||||
return [table] | ||||||
|
||||||
|
||||||
def setup(app: Sphinx) -> Dict[str, Any]: | ||||||
app.add_config_value("manifest_projects_table_manifest", None, "env") | ||||||
|
||||||
directives.register_directive("manifest-projects-table", ManifestProjectsTable) | ||||||
|
||||||
return { | ||||||
"version": __version__, | ||||||
"parallel_read_safe": True, | ||||||
"parallel_write_safe": True, | ||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,58 @@ | ||||||
:orphan: | ||||||
|
||||||
.. _west_projects_index: | ||||||
|
||||||
West Projects index | ||||||
################### | ||||||
|
||||||
See :ref:`external-contributions` for more information about | ||||||
this contributing and review process for imported components. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
Active Projects/Modules | ||||||
+++++++++++++++++++++++ | ||||||
|
||||||
The projects below are enabled by default and will be downloaded when you | ||||||
call `west update`. Many of the projects or modules listed below are | ||||||
essential for building generic Zephyr application and include among others | ||||||
hardware support for many of the platforms available in Zephyr. | ||||||
|
||||||
To disable any of the active modules, for example a specific HAL, use the | ||||||
following commands:: | ||||||
|
||||||
west config manifest.project-filter -- -hal_FOO | ||||||
west update | ||||||
|
||||||
.. manifest-projects-table:: | ||||||
:filter: active | ||||||
|
||||||
Inactive and Optional Projects/Modules | ||||||
++++++++++++++++++++++++++++++++++++++ | ||||||
|
||||||
|
||||||
The projects below are optional and will not be downloaded when you | ||||||
call `west update`. You can add any of the the projects or modules listed below | ||||||
and use them to write application code and extend your workspace with the added | ||||||
functionality. | ||||||
|
||||||
To enable any of the modules below, use the following commands:: | ||||||
|
||||||
west config manifest.project-filter -- +nanopb | ||||||
west update | ||||||
|
||||||
.. manifest-projects-table:: | ||||||
:filter: inactive | ||||||
|
||||||
External Projects/Modules | ||||||
++++++++++++++++++++++++++ | ||||||
nashif marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
|
||||||
The projects listed below are external and are not directly imported into the | ||||||
default manifest. | ||||||
To use any of the projects below, you will need to define your own manifest | ||||||
file which includes them. See :ref:`west-manifest-import` for information on | ||||||
recommended ways to do this while still inheriting the mandatory modules from | ||||||
Zephyr's :file:`west.yml`. | ||||||
|
||||||
.. rst-class:: rst-columns | ||||||
|
||||||
- TBD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.