Changeset 1022
- Timestamp:
- Jul 15, 2012 8:24:17 PM (11 years ago)
- Location:
- specdomain/trunk/src/specdomain/doc
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
specdomain/trunk/src/specdomain/doc/ex_markup/hkl_ioc.mac
r1021 r1022 1 #=============================================================================== 2 #**************SPEC macros for the Advanced Photon Source*********************** 3 #=============================================================================== 4 # 5 # Beamline/Sector: 4ID 6 # 7 # Macro Package: hkl_ioc.mac 8 # 9 # Version: 1.0 (August,2005) 10 # 11 # Description: A user defined calcHKL to write the current HKL postion to a 12 # soft IOC. It requires spec softioc running. 13 # 14 # Written by: X. Jiao 08/08/2005 15 # 16 # Modified by: 17 # 18 # User macros: ioc_HKL -> to turn on/off the feature of putting HKL to shared 19 # memory. 20 # 21 # Internal macros: ioc_put_HKL -> write HKL to the soft IOC 22 # 23 # Modification history: 24 # 25 #$Log$ 26 #Revision 1.3 2006/05/22 20:34:35 jiaox 27 #removed unsed lines in ioc_HKL. 28 # 29 #Revision 1.2 2006/05/11 17:46:31 jiaox 30 #Added CVS Log entry. 31 # 32 #=============================================================================== 1 """ 2 SPEC macros for the Advanced Photon Source 3 4 Beamline/Sector 5 4ID 6 7 Macro Package 8 hkl_ioc.mac 9 10 Version 11 1.0 (August,2005) 12 13 Description 14 A user defined calcHKL to write the current HKL postion to a 15 soft IOC. It requires spec softioc running. 16 17 Written by 18 X. Jiao 08/08/2005 19 20 Modified by: 21 22 User macros 23 ioc_HKL -> to turn on/off the feature of putting HKL to shared 24 memory. 25 26 Internal macros 27 ioc_put_HKL -> write HKL to the soft IOC 28 29 Modification history: 30 31 ======== =================== ======= ===================================== 32 Revision date/time author remarks 33 ======== =================== ======= ===================================== 34 1.3 2006/05/22 20:34:35 jiaox removed unsed lines in ioc_HKL. 35 1.2 2006/05/11 17:46:31 jiaox Added CVS Log entry. 36 ======== =================== ======= ===================================== 37 """ 33 38 34 39 #=============================================================================== … … 57 62 #=============================================================================== 58 63 def ioc_HKL '{ 64 """to turn on/off the feature of putting HKL to shared memory.""" 59 65 60 66 if($# != 1) { eprint "Usage: ioc_HKL on/off ";exit} … … 79 85 #=============================================================================== 80 86 def ioc_put_HKL ' 87 """write HKL to the soft IOC""" 88 81 89 epics_put(sprintf("%s:H",SIOC_PV),H) 82 90 epics_put(sprintf("%s:K",SIOC_PV),K) -
specdomain/trunk/src/specdomain/doc/howto-configure.rst
r1013 r1022 4 4 How to Create and Configure a Sphinx project to Document SPEC Macros 5 5 ==================================================================== 6 7 .. tip:: for more information on this topic, refer to the SPhinx tutorial: 8 http://sphinx.pocoo.org/tutorial.html 6 9 7 10 Decide which configuration … … 15 18 Then again, maybe not. 16 19 17 --tba--18 20 19 21 .. index:: ! in-source configuration 22 .. _in-source configuration: 20 23 21 24 In-source configuration -
specdomain/trunk/src/specdomain/doc/howto-markup.rst
r1021 r1022 9 9 #. apply markup 10 10 #. test 11 12 .. tip:: In addition to the Sphinx documentation (http://sphinx.pocoo.org), 13 a good reference how to document your macros can be found here: 14 http://stackoverflow.com/questions/4547849/good-examples-of-python-docstrings-for-sphinx 15 but a Google search for *sphinx python docstrings examples* will turn up a wealth of alternatives. 11 16 12 17 Basic SPEC Macro file … … 18 23 macro files, provides its documentation in SPEC comments, and has not been 19 24 marked up previously for documentation with Sphinx. Here is the file 20 ``hkl_ioc.mac``in its entirety.21 22 .. literalinclude:: ex_markup/hkl_ioc.mac 25 *hkl_ioc.mac* in its entirety. 26 27 .. literalinclude:: ex_markup/hkl_ioc.mac.original 23 28 :tab-width: 4 24 29 :linenos: … … 30 35 ============================== 31 36 32 .. tip:: Use an *in-source* configuration 33 .. make a reference to in-source 34 35 --tba-- 37 .. index:: in-source configuration 38 .. tip:: Use an :ref:`in-source configuration` 39 40 Make a project directory and change directory into it. 41 Copy the file above into this directory with the name *hkl_ioc.mac*. 42 Then run:: 43 44 sphinx-quickstart 45 46 Take most of the defaults. 47 These are the non-defaults for the example project: 48 49 ======================================================================================== ======================== 50 prompt response 51 ======================================================================================== ======================== 52 ``> Project name:`` **example** 53 ``> Author name(s):`` **SPEC Macro Writer** 54 ``> Project version:`` **1** 55 ``> autodoc: automatically insert docstrings from modules (y/N) [n]:`` **y** 56 ``> viewcode: include links to the source code of documented Python objects (y/N) [n]:`` **y** 57 ======================================================================================== ======================== 58 59 Edit the document ``index.rst`` so it looks like this:: 60 61 .. example documentation master file, created by 62 sphinx-quickstart on Sun Jul 15 17:54:46 2012. 63 You can adapt this file completely to your liking, but it should at least 64 contain the root `toctree` directive. 65 66 Welcome to example's documentation! 67 =================================== 68 69 .. autospecmacro:: hkl_ioc.mac 70 71 Contents: 72 73 .. toctree:: 74 :maxdepth: 2 75 76 77 78 Indices and tables 79 ================== 80 81 * :ref:`genindex` 82 * :ref:`modindex` 83 * :ref:`search` 84 85 Edit *conf.py* and make these changes (in order): 86 87 =================================================== ============================== 88 change location 89 =================================================== ============================== 90 ``extensions.append( 'sphinxcontrib.specdomain' )`` insert *after* line 28 91 =================================================== ============================== 92 93 The result should look like this file: :download:`ex_markup/conf.py`. 36 94 37 95 Apply Markup 38 96 ============================== 39 97 40 #. normal SPEC comments 98 .. tip:: We will edit the *hkl_ioc.mac* file now. 99 Before we start applying markup, 100 it's a good idea to make a backup copy of the original:: 101 102 cp hkl_ioc.mac hkl_ioc.mac.original 103 104 Here are the steps to consider when converting SPEC comments to reST markup. 105 106 #. identify the SPEC comments 41 107 #. extended comments (docstrings) 42 108 #. global docstring … … 45 111 #. descriptive comments 46 112 47 --tba-- 113 SPEC comments 114 ------------------ 115 116 Obvious as this sounds, it may help someone to see that the SPEC comments 117 are on lines 1-32. It is easy to place this entire block within an 118 extended comment [#]_ (known hereafter as a *docstring*). Make these 119 additions to lines 1 and 32: 120 121 ===== ============================================================================================= 122 line new 123 ===== ============================================================================================= 124 1 ``"""#===============================================================================`` 125 32 ``#==============================================================================="""`` 126 ===== ============================================================================================= 127 128 But this is not enough, as the content will look like a wreck. 129 130 -------------------------- 131 132 #=============================================================================== 133 #**************SPEC macros for the Advanced Photon Source*********************** 134 #=============================================================================== 135 # 136 # Beamline/Sector: 4ID 137 # 138 # Macro Package: hkl_ioc.mac 139 # 140 # Version: 1.0 (August,2005) 141 # 142 143 -------------------------- 144 145 ... and so forth 146 147 So, there is a choice to make. Either: 148 149 #. format the comment as literal text (least work) 150 #. reformat the as reST. (more work, looks better) 151 152 Literal text 153 ++++++++++++ 154 155 To format a SPEC comment as literal text, consider this brief SPEC comment: 156 157 .. code-block:: guess 158 :linenos: 159 160 # Summary: This macro scans the sample in a circular mesh. 161 # 162 # Dependencies: It is part of the circular mesh macro package. 163 164 Its literal text rendition in reST is written: 165 166 .. code-block:: guess 167 :linenos: 168 169 """ 170 :: 171 172 # Summary: This macro scans the sample in a circular mesh. 173 # 174 # Dependencies: It is part of the circular mesh macro package. 175 176 """ 177 178 which looks like: 179 180 ------------------- 181 182 :: 183 184 # Summary: This macro scans the sample in a circular mesh. 185 # 186 # Dependencies: It is part of the circular mesh macro package. 187 188 ------------------- 189 190 Note that the two colons indicate literal text follows. 191 Both the blank line after the colons and the final blank line are required to avoid warnings. 192 And, the entire comment must be indented at least one column to the right of the two colons. 193 194 reST markup 195 +++++++++++++ 196 197 In reST, the SPEC comment above might be written as two definition list items [#]_: 198 199 .. code-block:: guess 200 :linenos: 201 202 """ 203 Summary 204 This macro scans the sample in a circular mesh. 205 206 Dependencies 207 It is part of the circular mesh macro package. 208 209 """ 210 211 which looks like: 212 213 ------------------- 214 215 Summary 216 This macro scans the sample in a circular mesh. 217 218 Dependencies 219 It is part of the circular mesh macro package. 220 221 ------------------- 222 223 (The final blank line is necessary to avoid warnings.) 224 225 This markup does not look too complicated until we reach the *Modification history* 226 starting at line 23. The content here might be coded as either literal text (above) 227 or a reST table. Since the table is easy *and* CVS is no longer used, we'll 228 format it as a table. 229 230 Consider this SPEC comment: 231 232 .. code-block:: guess 233 :linenos: 234 235 #Revision 1.3 2006/05/22 20:34:35 jiaox 236 #removed unsed lines in ioc_HKL. 237 # 238 #Revision 1.2 2006/05/11 17:46:31 jiaox 239 #Added CVS Log entry. 240 241 It might be put into a table [#]_ such as: 242 243 .. code-block:: guess 244 :linenos: 245 246 ======== =================== ======= ===================================== 247 Revision date/time author remarks 248 ======== =================== ======= ===================================== 249 1.3 2006/05/22 20:34:35 jiaox removed unsed lines in ioc_HKL. 250 1.2 2006/05/11 17:46:31 jiaox Added CVS Log entry. 251 ======== =================== ======= ===================================== 252 253 which looks like: 254 255 ------------------- 256 257 ======== =================== ======= ===================================== 258 Revision date/time author remarks 259 ======== =================== ======= ===================================== 260 1.3 2006/05/22 20:34:35 jiaox removed unsed lines in ioc_HKL. 261 1.2 2006/05/11 17:46:31 jiaox Added CVS Log entry. 262 ======== =================== ======= ===================================== 263 264 ------------------- 265 266 267 268 Global Docstring 269 ------------------------- 270 271 The convention is to treat the first docstring in a macro file as the *global docstring*. 272 273 With these ideas in mind, 274 here is the markup of the first 32 lines: 275 276 .. code-block:: guess 277 :linenos: 278 279 """ 280 SPEC macros for the Advanced Photon Source 281 282 Beamline/Sector 283 4ID 284 285 Macro Package 286 hkl_ioc.mac 287 288 Version 289 1.0 (August,2005) 290 291 Description 292 A user defined calcHKL to write the current HKL postion to a 293 soft IOC. It requires spec softioc running. 294 295 Written by 296 X. Jiao 08/08/2005 297 298 Modified by: 299 300 User macros 301 ioc_HKL -> to turn on/off the feature of putting HKL to shared 302 memory. 303 304 Internal macros 305 ioc_put_HKL -> write HKL to the soft IOC 306 307 Modification history: 308 309 ======== =================== ======= ===================================== 310 Revision date/time author remarks 311 ======== =================== ======= ===================================== 312 1.3 2006/05/22 20:34:35 jiaox removed unsed lines in ioc_HKL. 313 1.2 2006/05/11 17:46:31 jiaox Added CVS Log entry. 314 ======== =================== ======= ===================================== 315 """ 316 317 which (except for the section title which is hard to render in this document) looks like: 318 319 ------------------- 320 321 Beamline/Sector 322 4ID 323 324 Macro Package 325 hkl_ioc.mac 326 327 Version 328 1.0 (August,2005) 329 330 Description 331 A user defined calcHKL to write the current HKL postion to a 332 soft IOC. It requires spec softioc running. 333 334 Written by 335 X. Jiao 08/08/2005 336 337 Modified by: 338 339 User macros 340 ioc_HKL -> to turn on/off the feature of putting HKL to shared 341 memory. 342 343 Internal macros 344 ioc_put_HKL -> write HKL to the soft IOC 345 346 Modification history: 347 348 ======== =================== ======= ===================================== 349 Revision date/time author remarks 350 ======== =================== ======= ===================================== 351 1.3 2006/05/22 20:34:35 jiaox removed unsed lines in ioc_HKL. 352 1.2 2006/05/11 17:46:31 jiaox Added CVS Log entry. 353 ======== =================== ======= ===================================== 354 355 ------------------- 356 48 357 49 358 Test 50 359 ----------- 51 360 52 --tba-- 361 Be sure to test your changes as you progress, until you are confident with reST markup. 362 The *make* process is efficient, only rebuilding the documentation from affected 363 .rst souce file changes. However, you might need to make sure changes in the .mac files 364 cause documentation to be rebuilt. It might be easier, although less efficient, 365 to rebuild your documentation each time. 366 367 :: 368 369 make clean html 370 371 372 This is usually very fast (seconds). 373 374 375 Docstring markup in each macro definition 376 --------------------------------------------- 377 378 Each of the macro definitions can be marked up to provide documentation with the definition. 379 The convention is to supply a short one-line summary first, then additional information as appropriate. 380 381 Consider the definition for ``ioc_HKL``. 382 A summary of it is given in the first comment section. 383 We'll apply that as the docstring: 384 385 .. code-block:: guess 386 :linenos: 387 388 def ioc_HKL '{ 389 """to turn on/off the feature of putting HKL to shared memory.""" 390 391 if($# != 1) { eprint "Usage: ioc_HKL on/off ";exit} 392 393 394 if(("$1" == "on")) { 395 cdef("user_save_HKL","ioc_put_HKL","ioc_HKL","0x20") 396 print "Now put HKL to softioc." 397 exit 398 } 399 if(("$1" == "off")) { 400 cdef("user_save_HKL","","ioc_HKL","delete") 401 print "Stop put HKL to softioc." 402 exit 403 } 404 eprint "Usage: ioc_HKL on/off " 405 }' 406 407 Do the same thing for the *ioc_put_HKL* macro definition. 408 409 410 ----------------- 411 412 .. rubric:: Footnotes 413 414 .. [#] a SPEC :ref:`extended comment <spec-extended-comments>` is text that is surrounded by three 415 double-quote characters (``"""``), such as: 416 417 """this is triple-quoted text is a docstring""" 418 419 In the Python language, this is known as a docstring. 420 But, **unlike Python**, SPEC does not recognize single quotes 421 to mark extended comments. Only use the double quote character. 422 .. [#] definition list: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#definition-lists 423 .. [#] table: http://sphinx.pocoo.org/rest.html#tables
Note: See TracChangeset
for help on using the changeset viewer.