Adds Links to Gem Directory and Documentation for Gems (#2922)

* Changed blue text to white that is not meant as a link, made 'View in Director' link work for gems in the inspector, added parsing for gem documentation link

Signed-off-by: nggieber <nggieber@amazon.com>

* Added documentation links for gems, changed markup for urls in summaries and requirements so they are clickable

Signed-off-by: nggieber <nggieber@amazon.com>

* Fixed a couple of the documentation links

Signed-off-by: nggieber <nggieber@amazon.com>

* Added documentation url to edit gem properties script and updated unit tests

Signed-off-by: nggieber <nggieber@amazon.com>
This commit is contained in:
AMZN-nggieber
2021-08-06 08:19:35 -07:00
committed by GitHub
parent 5a05fe93d4
commit 2c7f6f9742
83 changed files with 240 additions and 148 deletions
+12 -6
View File
@@ -53,6 +53,7 @@ def edit_gem_props(gem_path: pathlib.Path = None,
new_summary: str = None,
new_icon: str = None,
new_requirements: str = None,
new_documentation_url: str = None,
new_tags: list or str = None,
remove_tags: list or str = None,
replace_tags: list or str = None,
@@ -90,7 +91,9 @@ def edit_gem_props(gem_path: pathlib.Path = None,
if new_icon:
update_key_dict['icon_path'] = new_icon
if new_requirements:
update_key_dict['icon_requirements'] = new_requirements
update_key_dict['requirements'] = new_requirements
if new_documentation_url:
update_key_dict['documentation_url'] = new_documentation_url
update_key_dict['user_tags'] = update_values_in_key_list(gem_json_data.get('user_tags', []), new_tags,
remove_tags, replace_tags)
@@ -110,6 +113,7 @@ def _edit_gem_props(args: argparse) -> int:
args.gem_summary,
args.gem_icon,
args.gem_requirements,
args.gem_documentation_url,
args.add_tags,
args.remove_tags,
args.replace_tags)
@@ -129,20 +133,22 @@ def add_parser_args(parser):
group.add_argument('-go', '--gem-origin', type=str, required=False,
help='Sets description for gem origin.')
group.add_argument('-gt', '--gem-type', type=str, required=False, choices=['Code', 'Tool', 'Asset'],
help='Sets the gem type. Can only be one of the selected choices')
help='Sets the gem type. Can only be one of the selected choices.')
group.add_argument('-gs', '--gem-summary', type=str, required=False,
help='Sets the summary description of the gem.')
group.add_argument('-gi', '--gem-icon', type=str, required=False,
help='Sets the path to the projects icon resource.')
group.add_argument('-gr', '--gem-requirements', type=str, required=False,
help='Sets the description of the requirements needed to use the gem')
help='Sets the description of the requirements needed to use the gem.')
group.add_argument('-gdu', '--gem-documentation-url', type=str, required=False,
help='Sets the url for documentation of the gem.')
group = parser.add_mutually_exclusive_group(required=False)
group.add_argument('-at', '--add-tags', type=str, nargs='*', required=False,
help='Adds tag(s) to user_tags property. Can be specified multiple times')
help='Adds tag(s) to user_tags property. Can be specified multiple times.')
group.add_argument('-dt', '--remove-tags', type=str, nargs='*', required=False,
help='Removes tag(s) from the user_tags property. Can be specified multiple times')
help='Removes tag(s) from the user_tags property. Can be specified multiple times.')
group.add_argument('-rt', '--replace-tags', type=str, nargs='*', required=False,
help='Replace tag(s) in user_tags property. Can be specified multiple times')
help='Replace tag(s) in user_tags property. Can be specified multiple times.')
parser.set_defaults(func=_edit_gem_props)
+14 -9
View File
@@ -29,7 +29,8 @@ TEST_GEM_JSON_PAYLOAD = '''
"TestGem"
],
"icon_path": "preview.png",
"requirements": ""
"requirements": "",
"documentation_url": "https://o3de.org/docs/"
}
'''
@@ -44,24 +45,26 @@ def init_gem_json_data(request):
@pytest.mark.usefixtures('init_gem_json_data')
class TestEditGemProperties:
@pytest.mark.parametrize("gem_path, gem_name, gem_new_name, gem_display, gem_origin,\
gem_type, gem_summary, gem_icon, gem_requirements,\
gem_type, gem_summary, gem_icon, gem_requirements, gem_documentation_url,\
add_tags, remove_tags, replace_tags, expected_tags, expected_result", [
pytest.param(pathlib.PurePath('D:/TestProject'),
None, 'TestGem2', 'New Gem Name', 'O3DE', 'Code', 'Gem that exercises Default Gem Template',
'preview.png', '',
'new_preview.png', 'Do this extra thing', 'https://o3de.org/docs/user-guide/gems/',
['Physics', 'Rendering', 'Scripting'], None, None, ['TestGem', 'Physics', 'Rendering', 'Scripting'],
0),
pytest.param(None,
'TestGem2', None, 'New Gem Name', 'O3DE', 'Asset', 'Gem that exercises Default Gem Template',
'preview.png', '', None, ['Physics'], None, ['TestGem', 'Rendering', 'Scripting'], 0),
'new_preview.png', 'Do this extra thing', 'https://o3de.org/docs/user-guide/gems/', None,
['Physics'], None, ['TestGem', 'Rendering', 'Scripting'], 0),
pytest.param(None,
'TestGem2', None, 'New Gem Name', 'O3DE', 'Tool', 'Gem that exercises Default Gem Template',
'preview.png', '', None, None, ['Animation', 'TestGem'], ['Animation', 'TestGem'], 0)
'new_preview.png', 'Do this extra thing', 'https://o3de.org/docs/user-guide/gems/', None,
None, ['Animation', 'TestGem'], ['Animation', 'TestGem'], 0)
]
)
def test_edit_gem_properties(self, gem_path, gem_name, gem_new_name, gem_display, gem_origin,
gem_type, gem_summary, gem_icon, gem_requirements,
add_tags, remove_tags, replace_tags,
gem_type, gem_summary, gem_icon, gem_requirements,
gem_documentation_url, add_tags, remove_tags, replace_tags,
expected_tags, expected_result):
def get_gem_json_data(gem_path: pathlib.Path) -> dict:
@@ -79,7 +82,7 @@ class TestEditGemProperties:
patch('o3de.manifest.get_registered', side_effect=get_gem_path) as get_registered_patch:
result = gem_properties.edit_gem_props(gem_path, gem_name, gem_new_name, gem_display, gem_origin,
gem_type, gem_summary, gem_icon, gem_requirements,
add_tags, remove_tags, replace_tags)
gem_documentation_url, add_tags, remove_tags, replace_tags)
assert result == expected_result
if gem_new_name:
assert self.gem_json.data.get('gem_name', '') == gem_new_name
@@ -94,6 +97,8 @@ class TestEditGemProperties:
if gem_icon:
assert self.gem_json.data.get('icon_path', '') == gem_icon
if gem_requirements:
assert self.gem_json.data.get('requirments', '') == gem_requirements
assert self.gem_json.data.get('requirements', '') == gem_requirements
if gem_documentation_url:
assert self.gem_json.data.get('documentation_url', '') == gem_documentation_url
assert set(self.gem_json.data.get('user_tags', [])) == set(expected_tags)