Page MenuHome

Script to automatically update rna_manual_reference.py
ClosedPublic

Authored by Aaron Carlisle (Blendify) on Nov 25 2016, 10:37 PM.

Details

Summary

This script downloads the objects.inv file decodes it with sphobjinv (pip install sphobjinv) and generates a file.

This script is meant to be a stand alone script but we can git rid of sphobjinv and integrate it into Blender so the links are always up to date.
However, once we get manual versioning I do not think that would be necessary.

I am also unsure this is the right place for this script. The script should work as it however, their is only one link in the manual that works, the rest will be added once the svn server is fixed.

Diff Detail

Event Timeline

Aaron Carlisle (Blendify) retitled this revision from to Script to automatically update rna_manual_reference.py.
Aaron Carlisle (Blendify) updated this object.
Aaron Carlisle (Blendify) set the repository for this revision to rBDT Blender Dev Tools.
Aaron Carlisle (Blendify) planned changes to this revision.Dec 1 2016, 7:00 PM

The logic is not valid and has some corner cases.

Update script to work with new website

This is mostly functional but I am stuck on figuring out how to sort the lines depending on the length of split[0]
It would be nice to have this used for 2.79 so if anyone has any ideas that would be appreciated.

Another todo is I cannot figure out how to get around not saving the decode to a temp file.

utils/utils_rna_manual_reference_updater.py
106–108

Do not understand what you are trying to do here, care to give us a little example of input and expected output? ;)

The scripts downloads and decrypts the objects.inv file which looks like:

bpy.ops.ed. std:label -1 interface/undo_and_redo.html#bpy-ops-ed Undo and Redo
bpy.ops.ed.redo std:label -1 interface/undo_and_redo.html#bpy-ops-ed-redo Redo
bpy.ops.ed.undo std:label -1 interface/undo_and_redo.html#bpy-ops-ed-undo Undo
bpy.ops.ed.undo_history std:label -1 interface/undo_and_redo.html#bpy-ops-ed-undo-history Repeat History
bpy.types.armaturemodifier. std:label -1 modeling/modifiers/deform/armature.html#bpy-types-armaturemodifier Armature Modifier
bpy.types.cycles std:label -1 render/cycles/index.html#bpy-types-cycles Cycles Render Engine
bpy.types.cyclesrendersettings. std:label -1 render/cycles/settings/index.html#bpy-types-cyclesrendersettings Cycles Settings
bpy.types.cyclesrendersettings.max_subdivisions std:label -1 render/cycles/settings/scene/render/integrator.html#bpy-types-cyclesrendersettings-max-subdivisions -
bpy.types.object.location std:label -1 editors/3dview/object/properties/transforms.html#bpy-types-object-location Transform Properties
bpy.types.wavemodifier. std:label -1 modeling/modifiers/deform/wave.html#bpy-types-wavemodifier Wave Modifier

From here we need to take the two parts that we need, 1: The identifier (bpy.ops.ed.) and the url (interface/undo_and_redo.html#bpy-ops-ed).
This needs to be written in a way that matches: https://developer.blender.org/diffusion/BA/browse/master/modules/rna_manual_reference.py
The easiest way I found that will give the same results is the sort the list by the length of the identifier so that it finds more specific identifiers first.

OK, but in that case you cannot use for line in obj_temp:, since you need to sort all lines. Something like that should work?

with open("objects.tmp", encoding="utf8") as obj_tmp:
    lines = [l for l in obj_tmp if (l.startswith("bpy.types") or l.startswith('bpy.ops"))]
    lines.sort(key=lambda l: l.find(" "), reverse=True) # Finding first space will return length of rna path...
    for line in lines:
        split = line.split(" ")
        fw("\t(\"" + split[0] + "*\", \"" + split[3] + "\"),\n")

Yes, that works thanks for the tip.

This revision was automatically updated to reflect the committed changes.