Skip to content

Commit

Permalink
Add new plugin_name to DocSchema (#242)
Browse files Browse the repository at this point in the history
* Add new plugin_name to DocSchema

* default

* fix up fixtures

* fix up _pydantic_compat.py?

* Add changelog fragment.

---------

Co-authored-by: Felix Fontein <[email protected]>
  • Loading branch information
sivel and felixfontein authored Jan 30, 2024
1 parent 3078a8b commit 66e3562
Show file tree
Hide file tree
Showing 19 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/242-plugin_name-schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "Support new ``ansible-doc --json`` output field ``plugin_name`` (https://github.com/ansible-community/antsibull-docs/pull/242)."
6 changes: 3 additions & 3 deletions src/antsibull_docs/_pydantic_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from typing import TYPE_CHECKING, Any

import pydantic as p
import pydantic.version
from packaging.version import Version
from pydantic.version import VERSION as PYDANTIC_VERSION

pydantic_version = Version(p.version.VERSION)
pydantic_version = Version(PYDANTIC_VERSION)
HAS_PYDANTIC_V2 = pydantic_version.major == 2

if TYPE_CHECKING or HAS_PYDANTIC_V2:
Expand Down Expand Up @@ -51,7 +51,7 @@ def Field(*args: Any, **kwargs: Any) -> Any:
value = transform(value)
kwargs[new_key] = value
del kwargs[key]
return pydantic.Field(*args, **kwargs)
return p.Field(*args, **kwargs)


__all__ = ("pydantic_version", "HAS_PYDANTIC_V2", "Field", "v1")
1 change: 1 addition & 0 deletions src/antsibull_docs/schemas/docs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ class DocSchema(BaseModel):
collection: str = REQUIRED_COLLECTION_NAME_OR_EMPTY_STR_F
description: list[str]
name: str
plugin_name: str = ""
short_description: str
aliases: list[str] = []
author: list[str] = []
Expand Down
1 change: 1 addition & 0 deletions tests/functional/schema/good_data/one_become_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"version_added_collection": ""
}
},
"plugin_name": "",
"requirements": [],
"seealso": [],
"short_description": "Switch to elevated permissions on a network device",
Expand Down
1 change: 1 addition & 0 deletions tests/functional/schema/good_data/one_cache_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"version_added_collection": ""
}
},
"plugin_name": "",
"requirements": [],
"seealso": [],
"short_description": "JSON formatted files.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"name": "aws_resource_actions",
"notes": [],
"options": {},
"plugin_name": "",
"requirements": [
"whitelisting in configuration - see examples section below for details."
],
Expand Down
1 change: 1 addition & 0 deletions tests/functional/schema/good_data/one_cliconf_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"version_added_collection": ""
}
},
"plugin_name": "",
"requirements": [],
"seealso": [],
"short_description": "Use eos cliconf to run command on Arista EOS platform",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@
"version_added_collection": ""
}
},
"plugin_name": "",
"requirements": [],
"seealso": [],
"short_description": "Use httpapi to run command on network appliances",
Expand Down
1 change: 1 addition & 0 deletions tests/functional/schema/good_data/one_filter_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"true_val",
"false_val"
],
"plugin_name": "",
"requirements": [],
"seealso": [],
"short_description": "Ternary operation filter",
Expand Down
1 change: 1 addition & 0 deletions tests/functional/schema/good_data/one_httpapi_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"version_added_collection": ""
}
},
"plugin_name": "",
"requirements": [],
"seealso": [],
"short_description": "HttpApi Plugin for devices supporting Restconf API",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@
"version_added_collection": ""
}
},
"plugin_name": "",
"requirements": [
"boto3",
"botocore"
Expand Down
1 change: 1 addition & 0 deletions tests/functional/schema/good_data/one_lookup_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
}
},
"positional": [],
"plugin_name": "",
"requirements": [
"python-consul python library U(https://python-consul.readthedocs.io/en/latest/#installation)"
],
Expand Down
1 change: 1 addition & 0 deletions tests/functional/schema/good_data/one_module_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@
"version_added_collection": ""
}
},
"plugin_name": "",
"requirements": [],
"seealso": [
{
Expand Down
1 change: 1 addition & 0 deletions tests/functional/schema/good_data/one_netconf_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"version_added_collection": ""
}
},
"plugin_name": "",
"requirements": [],
"seealso": [],
"short_description": "Use iosxr netconf plugin to run netconf commands on Cisco IOSXR platform",
Expand Down
1 change: 1 addition & 0 deletions tests/functional/schema/good_data/one_shell_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
"version_added_collection": ""
}
},
"plugin_name": "",
"requirements": [],
"seealso": [],
"short_description": "POSIX shell (/bin/sh)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"name": "free",
"notes": [],
"options": {},
"plugin_name": "",
"requirements": [],
"seealso": [],
"short_description": "Executes tasks without waiting for all hosts",
Expand Down
1 change: 1 addition & 0 deletions tests/functional/schema/good_data/one_test_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
}
},
"positional": [],
"plugin_name": "",
"requirements": [],
"seealso": [],
"short_description": "check if task required changes",
Expand Down
1 change: 1 addition & 0 deletions tests/functional/schema/good_data/one_vars_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"version_added_collection": "foo.bar"
}
},
"plugin_name": "",
"requirements": [
"whitelist in configuration"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,7 @@
"version_added_collection": "ansible.builtin"
}
},
"plugin_name": "",
"requirements": [],
"seealso": [],
"short_description": "connect via ssh client binary",
Expand Down

0 comments on commit 66e3562

Please sign in to comment.