blob: e977566d265f0cefa8d93b2ac5e74d717b1ba0f2 [file] [log] [blame]
Derek Jones8ede1a22011-10-05 13:34:52 -05001#################################
2Writing CodeIgniter Documentation
3#################################
4
5CodeIgniter uses Sphinx to generate its documentation in a variety of formats,
6using reStructuredText to handle the formatting. If you are familiar with
7Markdown or Textile, you will quickly grasp reStructuredText. The focus is
8on readability, user friendliness, and an "I've got your hand, baby" feel.
9While they can be quite technical, we always write for humans!
10
11A table of contents should always be included like the one below.
12It is created automatically by inserting the ``.. contents::``
13directive on a line by itself.
14
15.. contents:: Page Contents
16
17
18**************
19Tools Required
20**************
21
22To see the rendered HTML, ePub, PDF, etc., you will need to install Sphinx
23along with the PHP domain extension for Sphinx. The underlying requirement
24is to have Python installed. Lastly, you will install the CI Lexer for
25Pygments, so that code blocks can be properly highlighted.
26
27.. code-block:: bash
28
29 easy_install sphinx
30 easy_install sphinxcontrib-phpdomain
31
32Then follow the directions in the README file in the :samp:`cilexer` folder
33inside the documentation repository to install the CI Lexer.
34
35
36
37*****************************************
38Page and Section Headings and Subheadings
39*****************************************
40
41Headings not only provide order and sections within a page, but they also
42are used to automatically build both the page and document table of contents.
43Headings are formed by using certain characters as underlines for a bit of
44text. Major headings, like page titles and section headings also use
45overlines. Other headings just use underlines, with the following hierarchy::
46
47 # with overline for page titles
48 * with overline for major sections
49 = for subsections
50 - for subsubsections
51 ^ for subsubsubsections
52 " for subsubsubsubsections (!)
53
54The :download:`TextMate ELDocs Bundle <./ELDocs.tmbundle.zip>` can help you
55create these with the following tab triggers::
56
57 title->
58
59 ##########
60 Page Title
61 ##########
62
63 sec->
64
65 *************
66 Major Section
67 *************
68
69 sub->
70
71 Subsection
72 ==========
73
74 sss->
75
76 SubSubSection
77 -------------
78
79 ssss->
80
81 SubSubSubSection
82 ^^^^^^^^^^^^^^^^
83
84 sssss->
85
86 SubSubSubSubSection (!)
87 """""""""""""""""""""""
88
89
90
91
92********************
93Method Documentation
94********************
95
96When documenting class methods for third party developers, Sphinx provides
97directives to assist and keep things simple. For example, consider the following
98ReST:
99
100.. code-block:: rst
101
102 .. php:class:: Some_class
103
104 some_method()
105 =============
106
107 .. php:method:: some_method ( $foo [, $bar [, $bat]])
108
109 This function will perform some action. The ``$bar`` array must contain
110 a something and something else, and along with ``$bat`` is an optional
111 parameter.
112
113 :param int $foo: the foo id to do something in
114 :param mixed $bar: A data array that must contain aa something and something else
115 :param bool $bat: whether or not to do something
116 :returns: FALSE on failure, TRUE if successful
117 :rtype: Boolean
118
119 ::
120
purwandi6f185982011-10-07 09:21:30 +0700121 $this->load->library('some_class');
Derek Jones8ede1a22011-10-05 13:34:52 -0500122
123 $bar = array(
124 'something' => 'Here is this parameter!',
125 'something_else' => 42
126 );
127
purwandi6f185982011-10-07 09:21:30 +0700128 $bat = $this->some_class->should_do_something();
Derek Jones8ede1a22011-10-05 13:34:52 -0500129
purwandi6f185982011-10-07 09:21:30 +0700130 if ($this->some_class->some_method(4, $bar, $bat) === FALSE)
Derek Jones8ede1a22011-10-05 13:34:52 -0500131 {
132 show_error('An Error Occurred Doing Some Method');
133 }
134
135 .. note:: Here is something that you should be aware of when using some_method().
136 For real.
137
138 See also :php:meth:`Some_class::should_do_something`
139
140 should_do_something()
141 =====================
142
143 .. php:method:: should_do_something()
144
145 :returns: whether or something should be done or not
146 :rtype: Boolean
147
148
149It creates the following display:
150
151.. php:class:: Some_class
152
153some_method()
154=============
155
156 .. php:method:: some_method ( $foo [, $bar [, $bat]])
157
158 This function will perform some action. The ``$bar`` array must contain
159 a something and something else, and along with ``$bat`` is an optional
160 parameter.
161
162 :param int $foo: the foo id to do something in
163 :param mixed $bar: A data array that must contain aa something and something else
164 :param bool $bat: whether or not to do something
165 :returns: FALSE on failure, TRUE if successful
166 :rtype: Boolean
167
168 ::
169
purwandi6f185982011-10-07 09:21:30 +0700170 $this->load->library('some_class');
Derek Jones8ede1a22011-10-05 13:34:52 -0500171
172 $bar = array(
173 'something' => 'Here is this parameter!',
174 'something_else' => 42
175 );
176
purwandi6f185982011-10-07 09:21:30 +0700177 $bat = $this->some_class->should_do_something();
Derek Jones8ede1a22011-10-05 13:34:52 -0500178
purwandi6f185982011-10-07 09:21:30 +0700179 if ($this->some_class->some_method(4, $bar, $bat) === FALSE)
Derek Jones8ede1a22011-10-05 13:34:52 -0500180 {
181 show_error('An Error Occurred Doing Some Method');
182 }
183
184 .. note:: Here is something that you should be aware of when using some_method().
185 For real.
186
187 See also :php:meth:`Some_class::should_do_something`
188
189should_do_something()
190=====================
191
192 .. php:method:: should_do_something()
193
194 :returns: whether or something should be done or not
195 :rtype: Boolean