Skip to content
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

Add new plugin_name to DocSchema #242

Merged
merged 5 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = ""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd make more sense to set this to None if it's not part of the docs schema.

Suggested change
plugin_name: str = ""
plugin_name: t.Optional[str] = None

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filename is also the same, it's added by ansible-doc and not part of the docs schema itself, was following that as my example.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, fair enough.

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
Loading