Page MenuHome

Addons: Allow a manual url prefix
ClosedPublic

Authored by Aaron Carlisle (Blendify) on Mar 2 2020, 8:41 PM.

Details

Summary

This was raised in T74017, the issue being that we point to /dev version of the manual for the addons when we want to point to a specific version instead.

Instead of manually updating the URL every release we can do this.

The bl_info for addons will need to be updated in the format of 'wiki_url': "$BLENDER_MANUAL_URL/addons/import_export/scene_gltf2.html",

Diff Detail

Event Timeline

Aaron Carlisle (Blendify) edited the summary of this revision. (Show Details)
release/scripts/modules/addon_utils.py
531–538

Constructing the manual URL only has to be done once. Blender won't change versions while it's running. This means that you could do it in a different function and decorate it with @functools.lru_cache(1).

538

I would use string formatting here, like this:

url = f"https://docs.blender.org/manual/en/{manual_version}"
540

There is no need to use string.Template just to replace a string. You can just do this instead:

addon_info["wiki_url"] = addon_info["wiki_url"].replace('$BLENDER_MANUAL_URL', url)
Sybren A. Stüvel (sybren) requested changes to this revision.Mar 3 2020, 5:32 PM
This revision now requires changes to proceed.Mar 3 2020, 5:32 PM
Brecht Van Lommel (brecht) added inline comments.
release/scripts/modules/addon_utils.py
531–538

Most developers won't know what @functools.lru_cache(1) is, none of this is performance critical so I prefer the code to be easy to understand.

  • Separate manual version into a function
  • Do not use string template
  • Use string formatting for URL

I decided to not use the decorate to stick to the programming style as Brecht suggested.

  • Use _ prefix for manual_version, since this isn't part of the public API.
  • Use {..} instead of $.. to allow {.._SUFFIX} later on.

We could set manual_version once, however this doesn't run on startup so I'm not too worried about this.

P1283

Update based on feedback

This revision was not accepted when it landed; it landed in state Needs Review.Mar 5 2020, 5:24 AM
This revision was automatically updated to reflect the committed changes.
  • Use {..} instead of $.. to allow {.._SUFFIX} later on.

This was originally proposed in T74017, but there (T74017#876887) I also said:

I like the idea, but this is very close to Python's f"" notation. Maybe "$BLENDER_MANUAL_URL/addons/import_export/scene_gltf2.html"? Or ${BLENDER_MANUAL_URL} if you want it to be more 'enclosed'.

Now the interpretation (by humans) of that string hinges on spotting the lack of f in front of the string. Since f-strings aren't that common yet, I think it's a good idea to use something more visibiliy different here. ${…_SUFFIX} also works fine.

Please don't commit too hastily, especially when a reviewer hasn't accepted a patch yet and when the new changes go against what that reviewer suggested earlier...