Page MenuHome

Addons: Deprecate wiki_url
ClosedPublic

Authored by Aaron Carlisle (Blendify) on Mar 4 2020, 12:01 AM.

Details

Summary

Now that addons are not documented on the wiki anymore wiki_url does not make much sense.

  • For 2.83 (LTS) a warning is hidden behind blender -d
  • 2.90 always show the warning
  • 2.93 (LTS) remove wiki_url

Diff Detail

Event Timeline

Brecht Van Lommel (brecht) added inline comments.
release/scripts/modules/addon_utils.py
543

depercated -> deprecated

Campbell Barton (campbellbarton) requested changes to this revision.EditedMar 4 2020, 8:06 AM

I'd prefer this be handled in addon_utils.module_bl_info, instead of the UI code, which gets a bit messy.

Made some other minor changes too:

  • Use the name "doc_url" since this is a URL which is useful to know (in keeping with "tracker_url").
  • Print the file path of the module with the warning, as this can be useful for quickly editing the add-on which needs updating.

1diff --git a/doc/python_api/examples/bpy.types.AddonPreferences.1.py b/doc/python_api/examples/bpy.types.AddonPreferences.1.py
2index 95285e8ac0c..0c82ff924de 100644
3--- a/doc/python_api/examples/bpy.types.AddonPreferences.1.py
4+++ b/doc/python_api/examples/bpy.types.AddonPreferences.1.py
5@@ -6,7 +6,7 @@ bl_info = {
6 "location": "SpaceBar Search -> Add-on Preferences Example",
7 "description": "Example Add-on",
8 "warning": "",
9- "wiki_url": "",
10+ "doc_url": "",
11 "tracker_url": "",
12 "category": "Object",
13 }
14diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py
15index b58c683dc24..27680e54596 100644
16--- a/release/scripts/modules/addon_utils.py
17+++ b/release/scripts/modules/addon_utils.py
18@@ -505,7 +505,7 @@ def module_bl_info(mod, info_basis=None):
19 "blender": (),
20 "location": "",
21 "description": "",
22- "wiki_url": "",
23+ "doc_url": "",
24 "support": 'COMMUNITY',
25 "category": "",
26 "warning": "",
27@@ -527,5 +527,19 @@ def module_bl_info(mod, info_basis=None):
28 if not addon_info["name"]:
29 addon_info["name"] = mod.__name__
30
31+ # Replace 'wiki_url' with 'doc_url'.
32+ doc_url = addon_info.pop("wiki_url", None)
33+ if doc_url is not None:
34+ # Unlikely, but possible.
35+ if not addon_info["doc_url"]:
36+ addon_info["doc_url"] = doc_url
37+ if _bpy.app.debug:
38+ addon_name = addon_info['name']
39+ addon_path = getattr(mod, "__file__", None)
40+ print(
41+ f"Warning: add-on {addon_name}: 'wiki_url' is deprecated please use "
42+ f"'doc_url' instead!\n {addon_path}"
43+ )
44+
45 addon_info["_init"] = None
46 return addon_info
47diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
48index 7e868b21e8a..c3c99ebb826 100644
49--- a/release/scripts/startup/bl_ui/space_userpref.py
50+++ b/release/scripts/startup/bl_ui/space_userpref.py
51@@ -1873,16 +1873,16 @@ class USERPREF_PT_addons(AddOnPanel, Panel):
52 split.label(text=" " + info["warning"], icon='ERROR')
53
54 user_addon = USERPREF_PT_addons.is_user_addon(mod, user_addon_paths)
55- tot_row = bool(info["wiki_url"]) + bool(user_addon)
56+ tot_row = bool(info["doc_url"]) + bool(user_addon)
57
58 if tot_row:
59 split = colsub.row().split(factor=0.15)
60 split.label(text="Internet:")
61 sub = split.row()
62- if info["wiki_url"]:
63+ if info["doc_url"]:
64 sub.operator(
65 "wm.url_open", text="Documentation", icon='HELP',
66- ).url = info["wiki_url"]
67+ ).url = info["doc_url"]
68 # Only add "Report a Bug" button if tracker_url is set
69 # or the add-on is bundled (use official tracker then).
70 if info.get("tracker_url"):

This revision now requires changes to proceed.Mar 4 2020, 8:06 AM

From Campbell's patch:

print(
    "Warning: add-on {:s}: 'wiki_url' is deprecated please use 'doc_url' instead!\n"
    "         {!r}".format(
    addon_info["name"],
    getattr(mod, "__file__", "<unknown>"),
))

I wouldn't use .format() any more now that we have f-strings. Rather would do this:

filename = getattr(mod, "__file__", "<unknown>")
print(
    f"Warning: add-on {addon_info['name']}: 'wiki_url' is deprecated please use "
    f"'doc_url' instead!\n         {filename}"
)

Note that I also removed the !r format string. !r would cause all backslashes in Windows paths to be escaped, which means you wouldn't be able to just copy-paste the path to an editor or file manager.

@Aaron Carlisle (Blendify) Please provide more context in the patch description. We've just talked about these changes, so it's fresh in our minds, but when someone wants to know the reasoning behind this change months or years from now, it'll be hard to follow.

Updated based on Sybren's suggestion.

This revision is now accepted and ready to land.Mar 5 2020, 1:45 AM
Ray Molenkamp (LazyDodo) retitled this revision from Addons: Depricate wiki_url to Addons: Deprecate wiki_url.Mar 5 2020, 2:09 AM