Skip to content

Commit 98f67fd

Browse files
committed
Add plugin description
1 parent e1f7ad6 commit 98f67fd

6 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ Static and runtime plugins differ only in how their instances enter the factory:
265265
266266
- `id` is required, identifies the plugin, and must be unique within the system. If discovery produces duplicate IDs, the first plugin is used and each later duplicate is invalid.
267267
- `displayName` is required display text and may repeat.
268+
- `description` is optional human-readable text for the plugin.
268269
- `version` is required and gives the current plugin version.
269270
- `compatVersion` is optional and defaults to `version`.
270271
- `enabledByDefault` is optional and defaults to `true`.
@@ -278,6 +279,7 @@ The metadata has the following schema:
278279
{
279280
"id": "org.example.editor",
280281
"displayName": "Editor",
282+
"description": "Provides the editor extension.",
281283
"version": "2.1.0",
282284
"compatVersion": "2.0.0",
283285
"enabledByDefault": true,

‎include/stdcorelib/pluginsystem/pluginspec.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ namespace stdc::pluginsystem {
6060
/// The display name, which does not have to be unique.
6161
const std::string &displayName() const;
6262

63+
/// A human-readable description of this plugin, or empty when none was provided.
64+
const std::string &description() const;
65+
6366
/// The plugin version.
6467
const VersionNumber &version() const;
6568

‎src/pluginsystem/pluginspec.cpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ namespace stdc::pluginsystem {
3838
return reportError("missing or invalid plugin display name");
3939
}
4040

41+
const auto &descriptionValue = metadata["description"];
42+
if (!descriptionValue.isNull()) {
43+
if (!descriptionValue.isString()) {
44+
return reportError("invalid plugin description");
45+
}
46+
description = descriptionValue.toString();
47+
}
48+
4149
std::string versionString;
4250
if (!readString("version", &versionString)) {
4351
return reportError("missing or invalid plugin version");
@@ -150,6 +158,10 @@ namespace stdc::pluginsystem {
150158
return _data->displayName;
151159
}
152160

161+
const std::string &PluginSpec::description() const {
162+
return _data->description;
163+
}
164+
153165
const VersionNumber &PluginSpec::version() const {
154166
return _data->version;
155167
}

‎src/pluginsystem/pluginspec_p.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace stdc::pluginsystem {
2222
std::string errorMessage;
2323
std::string id;
2424
std::string displayName;
25+
std::string description;
2526
VersionNumber version;
2627
VersionNumber compatVersion;
2728
std::vector<PluginDependency> dependencies;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"id": "org.stdcorelib.PluginSystemTest",
33
"displayName": "PluginSystem Test",
4+
"description": "A plugin system test plugin.",
45
"version": "2.1.0"
56
}

‎tests/auto/test_pluginsystem.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace {
3434
} else {
3535
addPlugin(
3636
"plugin",
37-
R"({"id":"org.stdcorelib.PluginSystemTest","displayName":"PluginSystem Test","version":"2.1.0"})");
37+
R"({"id":"org.stdcorelib.PluginSystemTest","displayName":"PluginSystem Test","description":"A plugin system test plugin.","version":"2.1.0"})");
3838
}
3939
}
4040

@@ -197,6 +197,7 @@ namespace {
197197
BOOST_CHECK(!specs.front()->hasError());
198198
BOOST_CHECK_EQUAL(specs.front()->id(), "org.stdcorelib.PluginSystemTest");
199199
BOOST_CHECK_EQUAL(specs.front()->displayName(), "PluginSystem Test");
200+
BOOST_CHECK_EQUAL(specs.front()->description(), "A plugin system test plugin.");
200201
BOOST_CHECK_EQUAL(specs.front()->version(), stdc::VersionNumber(2, 1));
201202
BOOST_CHECK_EQUAL(specs.front()->compatVersion(), specs.front()->version());
202203

0 commit comments

Comments
 (0)