Opened 11 years ago

Closed 11 years ago

#2458 closed enhancement (fixed)

De-duplication of icons from the python icon generator script

Reported by: Dietmar Winkler Owned by: Martin Sjölund
Priority: high Milestone: 1.9.1
Component: Backend Version: trunk
Keywords: Cc:

Description

The new icon generator has one major flaw and that is it is a proper space hog. Lot's of Modelica classes have the same icon (e.g., Modelica.Icons.Information) still the generator will save a separate copy for each of them. There is a rather simple solution that is based on the same de-duplication principle that Git VCS uses for the internal data storage. All files are saved not under their name but using the hash of their content as file name and an index to connect the original file name with the correct stored file name.

Something similar can be done for the icon file names and we should not even need an index file. Here is the principle as you can implement it in Python. Not really sure how to hook this into the GenDocumentation.mos really:

>>> import hashlib
>>> filename=hashlib.sha1("Modelica.Icons.Information").hexdigest()+'.svg'
>>> print  filename
43a93cda6b266a395248252cb4b69d1e9a0837af.svg

This means all classes using the same class as icon can simply point to same svg file. No need to store another version.

I could not really find a correct component to assign this ticket to. It should probably belong to "IconGenerator" or "Documentation Generator"

Change History (5)

comment:1 by Martin Sjölund, 11 years ago

Owner: changed from probably noone to Martin Sjölund
Status: newaccepted

You actually do need some way to connect the classname to the hash because the mos-script and python-script are different. Also, I need some way of removing <desc>Modelica.XXX.YYY</desc> from the svg because otherwise they are all different.

comment:2 by Martin Sjölund, 11 years ago

Resolution: fixed
Status: acceptedclosed

Fixed in r17968

comment:3 by Dietmar Winkler, 11 years ago

Resolution: fixed
Status: closedreopened

Two thinks I'm still missing in order to make this suitable for usage of a release generator:

  1. If readSymlinks = true then the symlinks should not be generated. (btw, unfortunate choice of name since it could be interpreted as "readABLESymlinks")
  2. There should be a "release" switch that does not generate all the space hungry json files. The whole de-duplication does not make sense if we keep the even larger jsons for ALL classes.

comment:4 by Dietmar Winkler, 11 years ago

I'am aware that this can be easily done in the script (see also m:r7114) but it would be more elegant if those file where not created in the first place depending on a "switch".

Version 0, edited 11 years ago by Dietmar Winkler (next)

comment:5 by Martin Sjölund, 11 years ago

Resolution: fixed
Status: reopenedclosed

"Fixed" in r17993, basically as above.

Note: See TracTickets for help on using tickets.