浏览代码

fixes #133 : Documenting lodel_admin.py actions implementation

Commit refs #122 and fixes #133
Yann Weber 8 年前
父节点
当前提交
80b8122dc4
共有 4 个文件被更改,包括 84 次插入2 次删除
  1. 1
    1
      install/Makefile
  2. 40
    0
      lodel/__init__.py
  3. 1
    0
      lodel/plugin/__init__.py
  4. 42
    1
      lodel/plugin/scripts.py

+ 1
- 1
install/Makefile 查看文件

@@ -11,5 +11,5 @@ init_db: dyncode
11 11
 list_hooks: dyncode
12 12
 	$(python) -c 'import lodel_admin; lodel_admin.list_registered_hooks()'
13 13
 
14
-discover_plugins:
14
+refresh_plugins:
15 15
 	$(python) -c 'import lodel_admin; lodel_admin.update_plugin_discover_cache()'

+ 40
- 0
lodel/__init__.py 查看文件

@@ -14,3 +14,43 @@ dyncode = None
14 14
 # 4. "lodel2_bootstraped" hooks are called
15 15
 # 5. "lodel2_loader_main" hooks are called (if runned from loader.py as main executable)
16 16
 #
17
+
18
+##@page lodel2_instance_admin Lodel2 instance administration
19
+#
20
+#@section lodel2_instance_adm_tools Tools
21
+#
22
+#@subsection lodel2_instance_makefile Makefile
23
+#
24
+#The Makefile allows to run automated without arguments such as :
25
+#- refresh the dynamic code using conf + EM (target **dyncode**)
26
+#- update databases (target **init_db**)
27
+#- refresh plugins list (target **refresh_plugins**)
28
+#
29
+#@subsection lodel2_instance_adm_scripts lodel_admin.py scripts
30
+#
31
+#In all instances you find a symlink named lodel_admin.py . This script
32
+#contains the code run by @ref lodel2_instance_makefile "Makefile targets"
33
+#and a main function that allows to run it as a CLI script.
34
+#
35
+#@par Script help
36
+#<pre>
37
+#usage: lodel_admin.py [-h] [-L] [ACTION] [OPTIONS [OPTIONS ...]]
38
+#
39
+#Lodel2 script runner
40
+#
41
+#positional arguments:
42
+#  ACTION              One of the following actions : discover-plugin [...]
43
+#  OPTIONS             Action options. Use lodel_admin.py ACTION -h to have
44
+#                      help on a specific action
45
+#
46
+#optional arguments:
47
+#  -h, --help          show this help message and exit
48
+#  -L, --list-actions  List available actions
49
+#</pre>
50
+#
51
+#@par Script customization
52
+#
53
+#See @ref lodel2_script_doc "Lodel2 scripting"
54
+#
55
+#
56
+

+ 1
- 0
lodel/plugin/__init__.py 查看文件

@@ -1,6 +1,7 @@
1 1
 #-*- coding: utf-8 -*-
2 2
 
3 3
 ##@defgroup lodel2_plugins Plugins
4
+#@ingroup lodel2_leapi
4 5
 #
5 6
 #Groups all stuff that concerns plugins
6 7
 

+ 42
- 1
lodel/plugin/scripts.py 查看文件

@@ -21,7 +21,7 @@ __registered_scripts = dict()
21 21
 #@ingroup lodel2_script
22 22
 #@ingroup lodel2_plugins
23 23
 #
24
-#Automatic script registration on child class declaration
24
+#Automatic action registration on child class declaration
25 25
 class MetaLodelScript(type):
26 26
     
27 27
     def __init__(self, name, bases, attrs):
@@ -177,3 +177,44 @@ def main_run():
177 177
     ret = script._run()
178 178
     ret = 0 if ret is None else ret
179 179
     exit(ret)
180
+
181
+##@page lodel2_script_doc Lodel2 scripting
182
+#@ingroup lodel2_script
183
+#
184
+#@section lodel2_script_adm Lodel2 instance administration scripts
185
+#
186
+#Lodel2 provides instance administration operation using Makefiles or 
187
+#lodel_admin.py script ( see @ref lodel2_instance_admin ).
188
+#
189
+#The lodel_admin.py script take as first option an action. Each action
190
+#correspond to a sub-script with it's own options etc. To get a list
191
+#of all available action run <code>python3 lodel_admin.py -L</code>.
192
+#
193
+#@section lodel2_script_action lodel_admin.py actions
194
+#
195
+#Action implementation is done by class inheritance. To create a new action
196
+#write a @ref lodel.plugin.scripts.LodelScript "LodelScript" derived class (
197
+#see @ref lodel.plugin.core_scripts "core_scripts.py" file as example )
198
+#
199
+#@subsection lodel2_script_inheritance LodelScript inheritance
200
+#
201
+#In order to implement properly a new action you have to write a new 
202
+#@ref lodel.plugin.scripts.LodelScript "LodelScript" derivated class.
203
+#Some methods and attributes are mandatory to write a fully functionnal
204
+#derivated class. Here is a list :
205
+#
206
+#- mandatory methods
207
+# - @ref plugin.scripts.LodelScript.argparser_config() "argparser_config()" :
208
+#(classmethod) initialize argparse.Parser
209
+# - @ref plugin.scripts.LodelScript.run() "run()" : (classmethod) contains the
210
+#code that runs to perform the action
211
+#- mandatory attributes
212
+# - @ref plugin.scripts.LodelScript::_action "_action" : (class attribute)
213
+#stores action name
214
+# - @ref plugin.scripts.LodelScript::_description "_description" : (class 
215
+#attribute) sotres a short action description
216
+#
217
+#@note On script's action registration : once child class is written you only
218
+#need to import it to trigger script's action registration (see
219
+#@ref plugin.scripts.MetaLodelScript )
220
+#

正在加载...
取消
保存