Skip to content

Commit

Permalink
GenerateDoc now lists the file a broken link was found in
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@16120 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed May 25, 2013
1 parent 936f447 commit 1b92a07
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
14 changes: 0 additions & 14 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3233,11 +3233,9 @@ span:hover .anchor {
@media screen {
a.ext-link .icon {
background: url(../extlink.gif) center center no-repeat;
padding-left: 12px;
}
a.mail-link .icon {
background: url(../envelope.png) center center no-repeat;
padding-left: 14px;
}
}
Expand Down Expand Up @@ -3334,15 +3332,13 @@ label.disabled { color: #d7d7d7 }
/* Main navigation bar */
#mainnav {
background: #fff url(../topbar_gradient.png) 0 0;
border: 1px solid #000;
font: normal 10px verdana,'Bitstream Vera Sans',helvetica,arial,sans-serif;
margin: .66em 0 .33em;
padding: .2em 0;
}
#mainnav li { border-right: none; padding: .25em 0 }
#mainnav :link, #mainnav :visited {
background: url(../dots.gif) 0 0 no-repeat;
border-right: 1px solid #fff;
border-bottom: none;
border-left: 1px solid #555;
Expand All @@ -3355,7 +3351,6 @@ label.disabled { color: #d7d7d7 }
border-right: 1px solid #ddd;
}
#mainnav .active :link, #mainnav .active :visited {
background: #000 url(../topbar_gradient2.png) 0 0 repeat-x;
border-top: none;
border-right: 1px solid #000;
color: #eee;
Expand Down Expand Up @@ -3409,8 +3404,6 @@ label.disabled { color: #d7d7d7 }
border: none;
padding: 0 0 2px;
}
#altlinks li a.ics { background-image: url(../ics.png); padding-left: 22px }
#altlinks li a.rss { background-image: url(../feed.png); padding-left: 20px }
/* Footer */
#footer {
Expand Down Expand Up @@ -3452,13 +3445,11 @@ label.disabled { color: #d7d7d7 }
/* Section folding */
.foldable :link, .foldable :visited {
background: url(../expanded.png) 0 50% no-repeat;
border: none;
padding-left: 16px;
}
.foldable :link:hover, .foldable :visited:hover { background-color: transparent }
.collapsed > .foldable :link, .collapsed > .foldable :visited {
background-image: url(../collapsed.png);
}
.collapsed > div, .collapsed > table, .collapsed > ul, .collapsed > dl { display: none }
fieldset > legend.foldable :link, fieldset > legend.foldable :visited {
Expand All @@ -3476,7 +3467,6 @@ fieldset > legend.foldable :link, fieldset > legend.foldable :visited {
position: relative;
margin: 0 1em 1em;
}
* html #prefs { width: 26em } /* Set width only for IE */
#prefs input, #prefs select { font-size: 9px; vertical-align: middle }
#prefs fieldset {
background: transparent;
Expand Down Expand Up @@ -3575,7 +3565,6 @@ table.wiki th {
width: 234px;
}
.wikitoolbar :link, .wikitoolbar :visited {
background: transparent url(../edit_toolbar.png) no-repeat;
border: 1px solid #fff;
border-left-color: #d7d7d7;
cursor: default;
Expand Down Expand Up @@ -3605,7 +3594,6 @@ div.trac-resizable textarea { display: block; margin-bottom: 0 }
div.trac-grip {
height: 5px;
overflow: hidden;
background: #eee url(../grip.png) no-repeat center 1px;
border: 1px solid #ddd;
border-top-width: 0;
cursor: s-resize;
Expand Down Expand Up @@ -3656,8 +3644,6 @@ table.listing th.asc a, table.listing th.desc a {
background-position: 100% 50%;
background-repeat: no-repeat;
}
table.listing th.asc a { background-image: url(../asc.png) }
table.listing th.desc a { background-image: url(../desc.png) }
table.listing tbody td, table.listing tbody th {
border: 1px dotted #ddd;
padding: .3em .5em;
Expand Down
25 changes: 16 additions & 9 deletions Examples/GenerateDoc.mos
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ writeFile(filetmp, version + " (<a href=\"ModelicaDocumentation.tar.xz\">Offline
writeFile(filetmp, "</body>\n</html>", append = true);

writeFile("Tidy.py","#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import with_statement
from BeautifulSoup import BeautifulSoup
import subprocess as sub
Expand All @@ -246,14 +247,19 @@ repls = ["+replaceCommands+"
(re.compile(r'[Mm][Oo][Dd][Ee][Ll][Ii][Cc][Aa]://([A-Za-z0-9.\\'()_]*#)'), r'\\1.html#'),
(re.compile(r'[Mm][Oo][Dd][Ee][Ll][Ii][Cc][Aa]://([A-Za-z0-9.\\'()_]*)'), r'\\1.html'),
]
rehttp = re.compile(r'https?://',flags=re.IGNORECASE)
links = open('tidy.links','w')

def linkreplace(link):
def linkreplace(link,filepath):
result = link
for (regex,repl) in repls:
try:
link = regex.sub(repl,link)
result = regex.sub(repl,result)
except:
pass
return link
if result <> link and not rehttp.match(result):
links.write('%s§%s\\n' % (result,filepath))
return result

for filepath in sorted(glob.glob('*.html')):
tag = '[Checking file %s]:\\n' % filepath
Expand All @@ -265,12 +271,12 @@ for filepath in sorted(glob.glob('*.html')):
soup = BeautifulSoup(html_file, fromEncoding='utf-8')
for a in soup.findAll('a'):
try:
a['href'] = linkreplace(a['href'])
a['href'] = linkreplace(a['href'],filepath)
except:
pass
for img in soup.findAll('img'):
try:
img['src'] = linkreplace(img['src'])
img['src'] = linkreplace(img['src'],filepath)
except:
pass
with open(filepath,'w') as html_file:
Expand All @@ -281,16 +287,17 @@ for filepath in sorted(glob.glob('*.html')):

writeFile("FindFiles.sh","#!/bin/bash
rm -f *.png *.pdf FindFiles.log
touch FindFiles.log
OMLIBRARY=\""+getInstallationDirectoryPath()+"/lib/omlibrary\"
grep -v http:// *.html | grep -v [Mm][Oo][Dd][Ee][Ll][Ii][Cc][Aa]:// | egrep -o \"[A-Za-z_0-9%.: -]*/[A-Za-z_0-9%.:/ -]*\\.(png|jpg|pdf)\" | cut -d: -f2- | sort -u | tr -d \\\" > tmp
for f in `cat tmp`; do
f=`echo $f | sed 's/%20/ /'`
for f in `uniq tidy.links`; do
f=`echo $f | cut -d§ -f1 | sed 's/%20/ /'`
if test -f \"$OMLIBRARY/$f\"; then
d=`dirname \"$f\"`
mkdir -p \"$d\"
cp \"$OMLIBRARY/$f\" \"$f\"
else
echo Not found: $f | tee -a FindFiles.log
inFile=`echo $f | cut -d§ -f2`
echo \"$inFile: Not found: $f\" | tee -a FindFiles.log
fi
done
rm -f tmp
Expand Down

0 comments on commit 1b92a07

Please sign in to comment.