# 編寫 CodeIgniter 的文檔
CodeIgniter 使用 Sphinx 來生成多種不同格式的文檔,并采用 reStructuredText 語法來編寫。 如果你熟悉 Markdown 或 Textile ,你會很快上手 reStructuredText 。我們的目標是可讀性 以及對用戶的友好性,盡管是非常技術性的文檔,但讀它的永遠是人類!
每一頁都應該包含該頁的一個目錄,就像下面這樣。它是通過下面的代碼自動創建的:
~~~
.. contents::
:local:
.. raw:: html
<div class="custom-index container"></div>
~~~
其中的 <div> 標簽采用了原始的 HTML 語法,它是文檔中的一個占位符,用于 JavaScript 動態的添加當前頁面上的任何方法和函數。
# 所需工具
要生成 HTML、ePub、PDF 等等這些格式的文檔,你需要先安裝 Sphinx 和 Sphinx 的 phpdomain 擴展,并確保你已經安裝了 Python 。然后安裝 CI Lexer for Pygments ,它可以正確的高亮 頁面中的代碼。
~~~
easy_install "sphinx==1.2.3"
easy_install "sphinxcontrib-phpdomain==0.1.3.post1"
~~~
然后按照 cilexer 目錄下的 README 文件的提示,來安裝 CI Lexer 。
# 頁面標題、小節標題 和 子標題
在一個頁面中標題可以用于對內容進行排序,將內容分成章節,而且還可以用于自動生成 頁面目錄以及整個文檔的目錄。可以使用特定的某些字符作為下劃線來表示標題,主標題 (例如頁面標題和小節標題)還需要使用上劃線,其他的標題只需要使用下劃線即可。 層次結構如下:
; # 頁面標題(帶上劃線)
; * 小節標題(帶上劃線)
; = 子標題
; - 子子標題
; ^ 子子子標題
; " 子子子子標題 (!)
使用 TextMate ELDocs Bundle 可以用下面這些 tab 快捷鍵快速創建這些標題:
~~~
title->
##########
Page Title
##########
sec->
*************
Major Section
*************
sub->
Subsection
==========
sss->
SubSubSection
-------------
ssss->
SubSubSubSection
^^^^^^^^^^^^^^^^
sssss->
SubSubSubSubSection (!)
"""""""""""""""""""""""
~~~
# 為方法編寫文檔
當你為其他開發者編寫類或方法的文檔時,Sphinx 提供了一些指令可以幫你簡單快速的完成。 例如,看下面的 ReST 語法:
~~~
.. php:class:: Some_class
.. php:method:: some_method ( $foo [, $bar [, $bat]])
This function will perform some action. The ``$bar`` array must contain
a something and something else, and along with ``$bat`` is an optional
parameter.
:param int $foo: the foo id to do something in
:param mixed $bar: A data array that must contain a something and something else
:param bool $bat: whether or not to do something
:returns: FALSE on failure, TRUE if successful
:rtype: bool
::
$this->load->library('some_class');
$bar = array(
'something' => 'Here is this parameter!',
'something_else' => 42
);
$bat = $this->some_class->should_do_something();
if ($this->some_class->some_method(4, $bar, $bat) === FALSE)
{
show_error('An Error Occurred Doing Some Method');
}
.. note:: Here is something that you should be aware of when using some_method().
For real.
See also :meth:`Some_class::should_do_something`
.. php:method:: should_do_something()
:returns: Whether or not something should be done
:rtype: bool
~~~
它生成的文檔如下所示:
class Some_class
some_method($foo[, $bar[, $bat]])
This function will perform some action. The $bar array must contain a something and something else, and along with $bat is an optional parameter.
參數:
*$foo (int) -- the foo id to do something in
*$bar (mixed) -- A data array that must contain a something and something else
*$bat (bool) -- whether or not to do something
返回:
FALSE on failure, TRUE if successful
返回類型:
bool
~~~
$this->load->library('some_class');
$bar = array(
'something' => 'Here is this parameter!',
'something_else' => 42
);
$bat = $this->some_class->should_do_something();
if ($this->some_class->some_method(4, $bar, $bat) === FALSE)
{
show_error('An Error Occurred Doing Some Method');
}
~~~
注釋
Here is something that you should be aware of when using some_method(). For real.
See also Some_class::should_do_something()
should_do_something()
返回: Whether or not something should be done
返回類型: bool
- 空白目錄
- 歡迎使用 CodeIgniter
- 安裝說明
- 下載CodeIgniter
- 安裝說明
- 從老版本升級
- 疑難解答
- CodeIgniter 概覽
- 開始
- CodeIgniter 是什么?
- 支持特性
- 應用程序流程圖
- 模型-視圖-控制器
- 架構目標
- 教程 - 內容提要
- 加載靜態內容
- 讀取新聞條目
- 創建新聞條目
- 結束語
- 向 CodeIgniter 貢獻你的力量
- 編寫 CodeIgniter 的文檔
- Developer's Certificate of Origin 1.1
- 常規主題
- CodeIgniter URL
- 控制器
- 保留名稱
- 視圖
- 模型
- 輔助函數
- 使用 CodeIgniter 類庫
- 創建類庫
- 使用 CodeIgniter 驅動器
- 創建驅動器
- 創建核心系統類
- 創建附屬類
- 鉤子 - 擴展框架核心
- 自動加載資源
- 公共函數
- 兼容性函數
- URI 路由
- 錯誤處理
- 網頁緩存
- 程序分析
- 以 CLI 方式運行
- 管理你的應用程序
- 處理多環境
- 在視圖文件中使用 PHP 替代語法
- 安全
- PHP 開發規范
- 類庫參考
- 基準測試類
- 緩存驅動器
- 日歷類
- 購物車類
- 配置類
- Email 類
- 加密類
- 加密類(新版)
- 文件上傳類
- 表單驗證類
- FTP 類
- 圖像處理類
- 輸入類
- Javascript 類
- 語言類
- 加載器類