Conditions | 1 |
Total Lines | 59 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | from unittest import TestCase |
||
40 | def test_referencing_latex(self): |
||
41 | verify_conversion( |
||
42 | self, |
||
43 | r""" |
||
44 | Title |
||
45 | ===== |
||
46 | |||
47 | Exercise -.#first |
||
48 | |||
49 | Exercise (Title) -.#second |
||
50 | |||
51 | See [%D %d %T %t %g %s %n # %c %p](#exercise:first) |
||
52 | |||
53 | See [%D %d %T %t %g %s %n # %c %p](#exercise:second) |
||
54 | """, |
||
55 | r""" |
||
56 | --- |
||
57 | header-includes: |
||
58 | - | |
||
59 | ` |
||
60 | \makeatletter |
||
61 | \@ifpackageloaded{subfig}{ |
||
62 | \usepackage[subfigure]{tocloft} |
||
63 | }{ |
||
64 | \usepackage{tocloft} |
||
65 | } |
||
66 | \makeatother |
||
67 | `{=tex} |
||
68 | - "`\\usepackage{etoolbox}`{=tex}" |
||
69 | - "`\\ifdef{\\mainmatter}{\\let\\oldmainmatter\\mainmatter\\renewcommand{\\mainmatter}[0]{\\oldmainmatter}}{}`{=tex}" |
||
70 | --- |
||
71 | |||
72 | ` |
||
73 | \makeatletter |
||
74 | \@ifpackageloaded{subfig}{ |
||
75 | \usepackage[subfigure]{tocloft} |
||
76 | }{ |
||
77 | \usepackage{tocloft} |
||
78 | } |
||
79 | \makeatother |
||
80 | `{=tex} |
||
81 | |||
82 | `\usepackage{etoolbox}`{=tex} |
||
83 | |||
84 | `\ifdef{\mainmatter}{\let\oldmainmatter\mainmatter\renewcommand{\mainmatter}[0]{\oldmainmatter}}{}`{=tex} |
||
85 | |||
86 | `\ifdef{\mainmatter}{}{}`{=tex} |
||
87 | |||
88 | # Title |
||
89 | |||
90 | `\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {1.1}{\ignorespaces {Exercise}}}`{=tex}[]{#exercise:title.1}[**Exercise 1**]{#exercise:first .pandoc-numbering-text .exercise .exercise-1-1 .exercise-first} |
||
91 | |||
92 | `\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {1.2}{\ignorespaces {Title}}}`{=tex}[]{#exercise:title.title}[**Exercise 2** *(Title)*]{#exercise:second .pandoc-numbering-text .exercise .exercise-1-2 .exercise-second} |
||
93 | |||
94 | See [Exercise exercise 1.1 1 1 1 2 `\pageref{exercise:first}`{=tex}](#exercise:first) |
||
95 | |||
96 | See [Exercise exercise Title title 1.2 1 2 2 2 `\pageref{exercise:second}`{=tex}](#exercise:second) |
||
97 | """, |
||
98 | "latex", |
||
99 | ) |
||
100 |