FNAL Redmine tricks » History » Version 4
Glenn Horton-Smith, 05/15/2019 11:07 AM
Add a couple more latex tricks.
1 | 1 | Katherine Lato | h1. FNAL Redmine tricks |
---|---|---|---|
2 | 1 | Katherine Lato | |
3 | 1 | Katherine Lato | {{>toc}} |
4 | 1 | Katherine Lato | |
5 | 1 | Katherine Lato | h2. Empty page - for testing |
6 | 1 | Katherine Lato | |
7 | 1 | Katherine Lato | An empty page for your tests: [[LArSoft Redmine sandbox]]; remember to clean up after yourself! |
8 | 1 | Katherine Lato | |
9 | 1 | Katherine Lato | h2. Calling macros |
10 | 1 | Katherine Lato | |
11 | 1 | Katherine Lato | A macro can be called by enclosing its name in double braces; for example: |
12 | 1 | Katherine Lato | <pre>{{hello_world(arg="argument text") |
13 | 1 | Katherine Lato | block of text |
14 | 1 | Katherine Lato | }}</pre> |
15 | 1 | Katherine Lato | |
16 | 1 | Katherine Lato | bq. {{hello_world(arg="argument text") |
17 | 1 | Katherine Lato | block of text |
18 | 1 | Katherine Lato | }} |
19 | 1 | Katherine Lato | |
20 | 1 | Katherine Lato | |
21 | 1 | Katherine Lato | h2. Syntax highlight for code |
22 | 1 | Katherine Lato | |
23 | 1 | Katherine Lato | The standard way to get some syntax highlight is to switch to HTML mode with. |
24 | 1 | Katherine Lato | |
25 | 1 | Katherine Lato | Class names are |
26 | 1 | Katherine Lato | |
27 | 1 | Katherine Lato | | C | @c@ | | |
28 | 1 | Katherine Lato | | C++ | @cpp@ | (does not know C++11 keywords) | |
29 | 1 | Katherine Lato | | python | @python@ | | |
30 | 1 | Katherine Lato | | ruby | @ruby@ | | |
31 | 1 | Katherine Lato | | JSON | @json@ | | |
32 | 1 | Katherine Lato | | bash | n/a | | |
33 | 1 | Katherine Lato | | FHiCL | n/a | (try with @python@) | |
34 | 1 | Katherine Lato | |
35 | 1 | Katherine Lato | {{collapse(Example with C++ code (class: "cpp")) |
36 | 1 | Katherine Lato | <pre><code class="cpp"> |
37 | 1 | Katherine Lato | /** |
38 | 1 | Katherine Lato | * @file ServiceUtils.h |
39 | 1 | Katherine Lato | * @brief Utility functions in `lar` namespace to interface with art services |
40 | 1 | Katherine Lato | * @author me@fnal.gov |
41 | 1 | Katherine Lato | * @date October 9th, 2015 |
42 | 1 | Katherine Lato | */ |
43 | 1 | Katherine Lato | #ifndef COREUTILS_SERVICEUTILS_H |
44 | 1 | Katherine Lato | #define COREUTILS_SERVICEUTILS_H |
45 | 1 | Katherine Lato | |
46 | 1 | Katherine Lato | // framework libraries |
47 | 1 | Katherine Lato | #include "art/Framework/Services/Registry/ServiceHandle.h" |
48 | 1 | Katherine Lato | #include "art/Utilities/Exception.h" |
49 | 1 | Katherine Lato | #include "cetlib/demangle.h" |
50 | 1 | Katherine Lato | |
51 | 1 | Katherine Lato | // C/C++ standard libraries |
52 | 1 | Katherine Lato | #include <typeinfo> |
53 | 1 | Katherine Lato | #include <type_traits> // std::is_copy_assignable<>, ... |
54 | 1 | Katherine Lato | |
55 | 1 | Katherine Lato | namespace lar { |
56 | 1 | Katherine Lato | |
57 | 1 | Katherine Lato | /** |
58 | 1 | Katherine Lato | * @brief Returns a constant pointer to the provider of specified service |
59 | 1 | Katherine Lato | * @tparam SERVICE the class of the service that is needed |
60 | 1 | Katherine Lato | * @return a constant, non-null pointer to the service provider |
61 | 1 | Katherine Lato | * @throw art::Exception if service returns a null pointer |
62 | 1 | Katherine Lato | * |
63 | 1 | Katherine Lato | * The service class is required to have a `provider_type` and a `provider()` |
64 | 1 | Katherine Lato | * members defined. |
65 | 1 | Katherine Lato | */ |
66 | 1 | Katherine Lato | template <typename SERVICE> |
67 | 1 | Katherine Lato | SERVICE const* providerFrom() { |
68 | 1 | Katherine Lato | // if you get a compilation error here, |
69 | 1 | Katherine Lato | // the service class your code is asking for does not comply with LArSoft |
70 | 1 | Katherine Lato | // service class requirements |
71 | 1 | Katherine Lato | static_assert( |
72 | 1 | Katherine Lato | !std::is_copy_constructible<typename SERVICE::provider_type>::value |
73 | 1 | Katherine Lato | && !std::is_move_constructible<typename SERVICE::provider_type>::value |
74 | 1 | Katherine Lato | && !std::is_copy_assignable<typename SERVICE::provider_type>::value |
75 | 1 | Katherine Lato | && !std::is_move_assignable<typename SERVICE::provider_type>::value, |
76 | 1 | Katherine Lato | "LArSoft service provider classes must not be copyable nor moveable!"); |
77 | 1 | Katherine Lato | SERVICE const* pProv = art::ServiceHandle<SERVICE>()->provider(); |
78 | 1 | Katherine Lato | if (!pProv) { |
79 | 1 | Katherine Lato | throw art::Exception(art::errors::NotFound) |
80 | 1 | Katherine Lato | << "Service " << cet::demangle(typeid(SERVICE).name()) |
81 | 1 | Katherine Lato | << " returned a null provider!"; |
82 | 1 | Katherine Lato | } |
83 | 1 | Katherine Lato | return pProv; |
84 | 1 | Katherine Lato | } // providerFrom() |
85 | 1 | Katherine Lato | |
86 | 1 | Katherine Lato | } // namespace lar |
87 | 1 | Katherine Lato | |
88 | 1 | Katherine Lato | #endif // COREUTILS_SERVICEUTILS_H |
89 | 1 | Katherine Lato | </code></pre> |
90 | 1 | Katherine Lato | }} |
91 | 1 | Katherine Lato | |
92 | 1 | Katherine Lato | {{collapse(Example with C code (class: "c")) |
93 | 1 | Katherine Lato | <pre><code class="c"> |
94 | 1 | Katherine Lato | #include <stdio.h> |
95 | 1 | Katherine Lato | |
96 | 1 | Katherine Lato | int main() { |
97 | 1 | Katherine Lato | int const n = 10; |
98 | 1 | Katherine Lato | for (int i = 0; i < n; ++i) { |
99 | 1 | Katherine Lato | printf ("Loop: %d\n", i); |
100 | 1 | Katherine Lato | } /* for */ |
101 | 1 | Katherine Lato | return 0; |
102 | 1 | Katherine Lato | } /* main() */ |
103 | 1 | Katherine Lato | </code></pre> |
104 | 1 | Katherine Lato | }} |
105 | 1 | Katherine Lato | |
106 | 1 | Katherine Lato | {{collapse(Example with python code (class: "python")) |
107 | 1 | Katherine Lato | <pre><code class="python"> |
108 | 1 | Katherine Lato | import sys |
109 | 1 | Katherine Lato | |
110 | 1 | Katherine Lato | if __name__ == "__main__": |
111 | 1 | Katherine Lato | print "%s got %d command line arguments: '%s'." \ |
112 | 1 | Katherine Lato | % (sys.argv[0], len(sys.argv) - 1, "', '".join(sys.argv[1:])) |
113 | 1 | Katherine Lato | sys.exit(0) |
114 | 1 | Katherine Lato | # main |
115 | 1 | Katherine Lato | </code></pre> |
116 | 1 | Katherine Lato | }} |
117 | 1 | Katherine Lato | |
118 | 1 | Katherine Lato | {{collapse(Example with FHiCL code (class: not supported but "python" may do)) |
119 | 1 | Katherine Lato | <pre><code class="python"> |
120 | 1 | Katherine Lato | #include "services.fcl" |
121 | 1 | Katherine Lato | |
122 | 1 | Katherine Lato | BEGIN_PROLOG |
123 | 1 | Katherine Lato | my_service: { |
124 | 1 | Katherine Lato | service_provider: "ReallyMyService" |
125 | 1 | Katherine Lato | |
126 | 1 | Katherine Lato | lower_limit: 10 |
127 | 1 | Katherine Lato | upper_limit: 20 |
128 | 1 | Katherine Lato | |
129 | 1 | Katherine Lato | } # my service |
130 | 1 | Katherine Lato | END_PROLOG |
131 | 1 | Katherine Lato | |
132 | 1 | Katherine Lato | services: { |
133 | 1 | Katherine Lato | IMyService: @local::my_service |
134 | 1 | Katherine Lato | } |
135 | 1 | Katherine Lato | |
136 | 1 | Katherine Lato | services.IMyService.upper_limit: 30 |
137 | 1 | Katherine Lato | services.IMyService.upper_limit: @erase |
138 | 1 | Katherine Lato | </code></pre> |
139 | 1 | Katherine Lato | }} |
140 | 1 | Katherine Lato | |
141 | 1 | Katherine Lato | {{collapse(Example with BASH code (class: not supported)) |
142 | 1 | Katherine Lato | <pre><code> |
143 | 1 | Katherine Lato | #!/usr/bin/env bash |
144 | 1 | Katherine Lato | # |
145 | 1 | Katherine Lato | # Print the full patch of each argument |
146 | 1 | Katherine Lato | # |
147 | 1 | Katherine Lato | |
148 | 1 | Katherine Lato | function ExpandPath() { |
149 | 1 | Katherine Lato | local Path="$1" |
150 | 1 | Katherine Lato | readlink -f "$Path" |
151 | 1 | Katherine Lato | } # ExpandPath() |
152 | 1 | Katherine Lato | |
153 | 1 | Katherine Lato | |
154 | 1 | Katherine Lato | for Param in "$@" ; do |
155 | 1 | Katherine Lato | ExpandPath "$Param" |
156 | 1 | Katherine Lato | done |
157 | 1 | Katherine Lato | |
158 | 1 | Katherine Lato | </code></pre> |
159 | 1 | Katherine Lato | }} |
160 | 1 | Katherine Lato | |
161 | 3 | Gianluca Petrillo | h2. References to other redmine locations |
162 | 1 | Katherine Lato | |
163 | 3 | Gianluca Petrillo | * *issue trackers*: @issue #1083@ renders as: issue #1083 (grayed and barred if closed); the numbering is unique within Fermilab Redmine |
164 | 3 | Gianluca Petrillo | * *source code*: |
165 | 3 | Gianluca Petrillo | ** @source:bin/CMakeLists.txt@ renders as: source:bin/CMakeLists.txt |
166 | 3 | Gianluca Petrillo | ** @lardata:source:ups/product_deps@ renders as: lardata:source:ups/product_deps |
167 | 3 | Gianluca Petrillo | * *commits*: @lardata:commit:ce08cb0c03376890c3e9339edf95d9ce10ffb377@ or shortened @lardata:commit:ce08cb0@ render as lardata:commit:ce08cb0c03376890c3e9339edf95d9ce10ffb377 and lardata:commit:ce08cb0 respectively (both point to the same place) |
168 | 3 | Gianluca Petrillo | * *wiki pages*: the labels can be obtained from the page and section titles, removing all "special" characters |
169 | 3 | Gianluca Petrillo | ** @[[art:]]@ points to the main wiki page of _art_ Redmine project: [[art:]] (@[[art:|art wiki]]@ typesets the specified label: [[art:|art wiki]]) |
170 | 3 | Gianluca Petrillo | ** @[[FNAL Redmine tricks]]@ points to this wiki page: [[FNAL Redmine tricks]] (@[[FNAL Redmine tricks|tricks]]@ typesets the specified label: [[FNAL Redmine tricks|tricks]]) |
171 | 3 | Gianluca Petrillo | ** @[[FNAL Redmine tricks#References to other redmine locations]]@ points to this paragraph: [[FNAL Redmine tricks#References to other redmine locations]] (label syntax available as above) |
172 | 3 | Gianluca Petrillo | ** @[[art:Configuration validation and description]]@ points to a specific wiki page of the redmine project _art_: [[art:Configuration validation and description]] (label syntax available as above) |
173 | 3 | Gianluca Petrillo | * *projects*: @project:art@ renders as project:art |
174 | 3 | Gianluca Petrillo | * *versions*: versions are declared in the @Settings@ panel of a Redmine project |
175 | 3 | Gianluca Petrillo | ** @version:v06_49_00@ renders as version:v06_49_00 |
176 | 3 | Gianluca Petrillo | ** @art:version:2.09.00@ renders as art:version:2.09.00 |
177 | 1 | Katherine Lato | |
178 | 1 | Katherine Lato | h2. Custom macro test |
179 | 1 | Katherine Lato | |
180 | 1 | Katherine Lato | _(this is currently incorrect or not working)_ |
181 | 1 | Katherine Lato | |
182 | 1 | Katherine Lato | macro :my_macro, :desc => 'This is a custom macro' do |obj, args| |
183 | 1 | Katherine Lato | # args is an array |
184 | 1 | Katherine Lato | # and this macro does not accept a block of text |
185 | 1 | Katherine Lato | end |
186 | 1 | Katherine Lato | |
187 | 1 | Katherine Lato | {{my_macro}} |
188 | 1 | Katherine Lato | |
189 | 1 | Katherine Lato | |
190 | 1 | Katherine Lato | h2. Collapsing text |
191 | 1 | Katherine Lato | |
192 | 1 | Katherine Lato | The following macro creates a collapsible window with the specified text as short description. |
193 | 1 | Katherine Lato | The extended text can contain macros; e.g.: |
194 | 1 | Katherine Lato | <pre>{{collapse(View details...) |
195 | 1 | Katherine Lato | bq. {{child_pages}} |
196 | 1 | Katherine Lato | This is a block of text that is collapsed by default. |
197 | 1 | Katherine Lato | It can be expanded by clicking a link. |
198 | 1 | Katherine Lato | }}</pre> |
199 | 1 | Katherine Lato | |
200 | 1 | Katherine Lato | {{collapse(View details...) |
201 | 1 | Katherine Lato | bq. {{child_pages}} |
202 | 1 | Katherine Lato | This is a block of text that is collapsed by default. |
203 | 1 | Katherine Lato | It can be expanded by clicking a link. |
204 | 1 | Katherine Lato | }} |
205 | 1 | Katherine Lato | |
206 | 1 | Katherine Lato | |
207 | 1 | Katherine Lato | h2. Mathematical formulas with LaTeX |
208 | 1 | Katherine Lato | |
209 | 1 | Katherine Lato | <pre>{{latex($\beta\tau\Theta\theta$)}}</pre> |
210 | 1 | Katherine Lato | |
211 | 1 | Katherine Lato | bq. {{latex($\beta\tau\Theta\theta$)}} |
212 | 1 | Katherine Lato | |
213 | 4 | Glenn Horton-Smith | h2. Other tricks with LaTeX |
214 | 4 | Glenn Horton-Smith | |
215 | 4 | Glenn Horton-Smith | Today's date: {{latex(\today)}} |
216 | 4 | Glenn Horton-Smith | |
217 | 4 | Glenn Horton-Smith | Minutes since midnight: {{latex(\the\time)}} |
218 | 1 | Katherine Lato | |
219 | 1 | Katherine Lato | h2. DOT graphs |
220 | 1 | Katherine Lato | |
221 | 1 | Katherine Lato | This seems not to work... |
222 | 1 | Katherine Lato | <pre>{{graphviz( a -> b ;)}}</pre> |
223 | 1 | Katherine Lato | |
224 | 1 | Katherine Lato | bq. {{graphviz( a -> b ;)}} |
225 | 1 | Katherine Lato | |
226 | 1 | Katherine Lato | |
227 | 1 | Katherine Lato | h2. List of supported macros |
228 | 1 | Katherine Lato | |
229 | 1 | Katherine Lato | The following list can be rendered by running the @{{macro_list}}@ macro: |
230 | 1 | Katherine Lato | |
231 | 1 | Katherine Lato | --- |
232 | 1 | Katherine Lato | |
233 | 1 | Katherine Lato | {{macro_list}} |
234 | 1 | Katherine Lato | |
235 | 3 | Gianluca Petrillo | --- |