| | 170 | def make_apidocs(x,y,width,height,scale_factor=0.5,_debug=False): |
|---|
| | 171 | global poster, styles |
|---|
| | 172 | svn_client = pysvn.Client() |
|---|
| | 173 | svn_client.checkout(svnpath, "pyNN") |
|---|
| | 174 | wikidoc = imp.load_source('wikidoc', os.path.join('pyNN','doc','wikidoc.py')) |
|---|
| | 175 | import re |
|---|
| | 176 | from pyNN import __version__ |
|---|
| | 177 | __version__ = ".".join(__version__.split('.')[0:2]) # x.y.z --> x.y |
|---|
| | 178 | paragraph_template = re.compile(r'<para( style="(?P<style>\S*)")?>(?P<content>.*?)</para>',re.DOTALL) |
|---|
| | 179 | |
|---|
| | 180 | for style_name,parent in [('APIBody', 'BodyText'), ('FunctionDef','Heading3'), |
|---|
| | 181 | ('Category','Heading1'),('Class','Heading2')]: |
|---|
| | 182 | newstyle = ParagraphStyle(style_name, parent=styles[parent]) |
|---|
| | 183 | scale_style(newstyle, scale_factor) |
|---|
| | 184 | styles.add(newstyle) |
|---|
| | 185 | styles[style_name].alignment = TA_LEFT |
|---|
| | 186 | styles['FunctionDef'].textColor = colors.blue |
|---|
| | 187 | styles['FunctionDef'].fontName = styles['APIBody'].fontName |
|---|
| | 188 | styles['FunctionDef'].spaceBefore *= 0.3 |
|---|
| | 189 | styles['FunctionDef'].spaceAfter *= 0.3 |
|---|
| | 190 | styles['Category'].spaceBefore = styles['FunctionDef'].spaceBefore*2 |
|---|
| | 191 | styles['Class'].textColor = colors.darkgreen |
|---|
| | 192 | styles['Class'].spaceBefore *= 0.3 |
|---|
| | 193 | styles['Class'].spaceAfter *= 0.3 |
|---|
| | 194 | styles['APIBody'].spaceBefore = 0 |
|---|
| | 195 | styles['APIBody'].fontSize += 1 |
|---|
| | 196 | styles['APIBody'].leading += 1 |
|---|
| | 197 | print "APIBody ", styles['APIBody'].fontSize |
|---|
| | 198 | ##print styles['FunctionDef'].listAttrs() |
|---|
| | 199 | |
|---|
| | 200 | apidoc = wikidoc.apidoc('reportlab_xml') |
|---|
| | 201 | #print apidoc |
|---|
| | 202 | margin = 0.03 |
|---|
| | 203 | subcol_width = width*(1-margin)/2.0 |
|---|
| | 204 | |
|---|
| | 205 | |
|---|
| | 206 | paragraph_list = [Paragraph("API reference <font size=14>(version %s)</font>" % __version__, styles['UsersGuideHeading1'])] |
|---|
| | 207 | for match in paragraph_template.finditer(apidoc): |
|---|
| | 208 | groups = match.groupdict() |
|---|
| | 209 | content = groups['content'] |
|---|
| | 210 | if groups['style'] is None: |
|---|
| | 211 | style = "APIBody" |
|---|
| | 212 | else: |
|---|
| | 213 | style = groups['style'] |
|---|
| | 214 | paragraph_list += [Paragraph(content, styles[style])] |
|---|
| | 215 | #apidoc_frame.add(Paragraph(content, styles[style]), poster) |
|---|
| | 216 | pad = 0.5*cm |
|---|
| | 217 | f_height = 0 |
|---|
| | 218 | for p in paragraph_list: |
|---|
| | 219 | f_height += p.wrap(subcol_width-pad, pageheight)[1] + p.getSpaceAfter() + p.getSpaceBefore() |
|---|
| | 220 | f_height = f_height/2.0 + 2*pad |
|---|
| | 221 | apidoc_frame1 = Frame(x, y - height, subcol_width, f_height, showBoundary=_debug, |
|---|
| | 222 | leftPadding=pad, rightPadding=0, bottomPadding=pad, |
|---|
| | 223 | topPadding=pad) |
|---|
| | 224 | apidoc_frame2 = Frame(x+width-subcol_width, y - height, subcol_width, f_height, showBoundary=_debug, |
|---|
| | 225 | leftPadding=0, rightPadding=pad, bottomPadding=pad, |
|---|
| | 226 | topPadding=pad) |
|---|
| | 227 | apidoc_frame1.addFromList(paragraph_list, poster) |
|---|
| | 228 | apidoc_frame2.addFromList(paragraph_list, poster) |
|---|
| | 229 | assert len(paragraph_list) == 0 |
|---|
| | 230 | poster.roundRect(x,y-height,width,f_height,1*cm) |
|---|
| | 231 | |
|---|