This page is for notes on the possibility of automated scripts for migrating from {{Family tree}} to {{Tree chart}}.
As noted in the discussion at Template talk:Family tree#Skilled Wikipedians needed there are two cases where automation could be used:
- Use of tiles that have changed plus lines that end
|}}
as per Template:Tree chart#Migration from familytree. - Use of box names (that get substituted for the actual content of the boxes) that clash with Tree chart's tile names.
Both could be dealt with by a script that finds uses of {{Family tree}}, {{family tree}} & {{familytree}} and for each use:
- Makes the substitutions as per the instructions at Template:Tree chart#Migration from familytree taking care to create an order of substitution that prevents double substitution, and replaces
|}}
with| }}
. - Rather than look for name clashes it would be easier to look for single character box names (
?=
) in each use and append the characterx
to them.
In constructing the script it will be important to be able to deal with cases where there is additional white space, such as | E |
.
In addition the output should as far as possible preserve the same layout. Particularly box names that immediately follow the initial pipe (|
) must not have space inserted before them, as this will break any styling that is applied to the box. However It will not be possible to preserve layout in cases where the {{tree chart}} tile name is two characters, such as ye
.
Order in which to make substitutions to prevent double substitution
editThe following table is based on Template:Tree chart#Migration from familytree.
Tile | {{family tree}} | {{tree chart}} | Notes on parameters | ||||
---|---|---|---|---|---|---|---|
c |
fh |
Change | |||||
d |
ic |
Change | |||||
j |
he |
Change | |||||
{ |
c |
Change | |||||
3 |
c |
Change | |||||
} |
d |
Change | |||||
E |
d |
Change | |||||
t |
i |
Change | |||||
# |
t |
Change | |||||
[ |
e |
Change | |||||
] |
f |
Change | |||||
u |
j |
Change | |||||
b |
di |
Change | |||||
n |
ye |
Change | |||||
p |
dj |
Change | |||||
q |
jc |
Change | |||||
r |
fy |
Change | |||||
G |
G2 |
Change | |||||
T |
T2 |
Change | |||||
k |
l4 |
Change |
Creating list of what links here for Template:Family tree
edit- Obtain list from https://en.wikipedia.org/w/index.php?title=Special:WhatLinksHere/Template:Family_tree&limit=2000&hidelinks=1&hideredirs=1 (which has links and redirects turned off) and put in a text file (
t.txt
). - Do a global edit to remove "
(transclusion) (links | edit)
". - Sort the list and delete duplicates. (
$ sort t.txt | uniq >u.txt
). - Divide the list into pages in article space (
$ grep -v : u.txt >v.txt
) and those not in article space ($ grep : u.txt >w.txt
). - Create a table to record observations from list of pages in article space using a short awk script (
$ awk -f table.awk <v.txt >x.txt
)
The awk script (table.awk
) to create the table is:
BEGIN { print "{| class='wikitable sortable'"; print "|-"; print "! Page"; print "!class=unsortable| edit"; print "! Notes"; print "|-"; }
{ print "| [[" $0 "]]"; line=$0; gsub(" ","_",line); printf("| [https://en.wikipedia.org/w/index.php?title=%s&action=edit edit]\n",line); print "|"; print "|-"; }
END { print "|}"; }
Transclusions
editHere is the list of transclusions of {{Family tree}} (method of creation described above) as of 29 April 2020:
In the Notes column:
- Compatible means that the use of {{Family tree}} will not break if there is a redirect to {{Tree chart}}.
- Change required means that the use of {{Family tree}} will have to be migrated to {{Tree chart}} because it is not compatible.
- Further investigation means that further investigation is required to determine if it is Compatible or if Change required.