檢視原始碼 shell_docs (stdlib v6.2)

用於為 shell 渲染 EEP-48 風格文件的函式。

此模組可用於渲染函式和類型文件,以便在 shell 中列印。此模組用於渲染通過 shell 使用 c:h/1,2,3 存取的文件。範例

1> h(maps,new,0).

  -spec new() -> Map when Map :: #{}.

Since:
  OTP 17.0

  Returns a new empty map.

  Example:

    > maps:new().
    #{}

此模組會格式化並渲染格式為 application/erlang+html 的 EEP-48 文件。如需更多關於此格式的資訊,請參閱 EDoc 使用者指南中的文件儲存。它也可以渲染任何其他 "text" 類型的格式,儘管這些格式將會照原樣渲染。

摘要

類型

application/erlang+html 中允許使用的 HTML 標籤。

文件應如何渲染的組態。

保存模組 EEP-48 文件的記錄。您可以使用 code:get_doc/1 從模組中獲取此資訊。

函式

此函式可用於對 application/erlang+html 文件進行空白字元正規化。

渲染模組或函式文件。

渲染模組中的所有回呼或回呼文件。

渲染模組中回呼的文件。

渲染模組中的所有類型或類型文件。

渲染模組中類型的文件。

此函式可用於找出 application/erlang+html 文件支援哪些標籤。

此函式可用於對 application/erlang+html 格式的文件內容進行基本驗證。

類型

連結至此類型

chunk_element()

檢視原始碼 (未匯出) (自 OTP 23.0 起)
-type chunk_element() :: {chunk_element_type(), chunk_element_attrs(), chunk_elements()} | binary().
連結至此類型

chunk_element_attr()

檢視原始碼 (自 OTP 23.0 起)
-type chunk_element_attr() :: {atom(), unicode:chardata()}.
連結至此類型

chunk_element_attrs()

檢視原始碼 (未匯出) (自 OTP 23.0 起)
-type chunk_element_attrs() :: [chunk_element_attr()].
連結至此類型

chunk_element_block_type()

檢視原始碼 (未匯出) (自 OTP 23.0 起)
-type chunk_element_block_type() ::
          p | 'div' | blockquote | br | pre | ul | ol | li | dl | dt | dd | h1 | h2 | h3 | h4 | h5 | h6.
連結至此類型

chunk_element_inline_type()

檢視原始碼 (未匯出) (自 OTP 23.0 起)
-type chunk_element_inline_type() :: a | code | em | strong | i | b.
連結至此類型

chunk_element_type()

檢視原始碼 (未匯出) (自 OTP 23.0 起)
-type chunk_element_type() :: chunk_element_inline_type() | chunk_element_block_type().

application/erlang+html 中允許使用的 HTML 標籤。

連結至此類型

chunk_elements()

檢視原始碼 (自 OTP 23.0 起)
-type chunk_elements() :: [chunk_element()].
連結至此類型

config()

檢視原始碼 (未匯出) (自 OTP 23.2 起)
-type config() :: #{encoding => unicode | latin1, columns => pos_integer(), ansi => boolean()}.

文件應如何渲染的組態。

  • encoding - 設定渲染器應用於圖形細節(例如項目符號)的編碼。預設情況下,shell_docs 會使用 io:getopts() 傳回的值。

  • ansi - 設定是否應使用 ansi 跳脫碼來渲染圖形細節,例如粗體和底線。預設情況下,shell_docs 會嘗試判斷接收 shell 是否支援 ansi 跳脫碼。可以將核心組態參數 shell_docs_ansi 設定為 boolean/0 值來覆寫自動檢查。

  • columns - 設定目標文件應渲染的寬度。預設情況下,shell_docs 會使用 io:columns() 傳回的值。

連結至此類型

docs_v1()

檢視原始碼 (未匯出) (自 OTP 23.0 起)
-type docs_v1() ::
          #docs_v1{anno :: term(),
                   beam_language :: term(),
                   format :: term(),
                   module_doc :: term(),
                   metadata :: term(),
                   docs :: term()}.

保存模組 EEP-48 文件的記錄。您可以使用 code:get_doc/1 從模組中獲取此資訊。

函式

連結至此函式

normalize(Docs)

檢視原始碼 (自 OTP 23.0 起)
-spec normalize(Docs) -> NormalizedDocs
                   when Docs :: chunk_elements(), NormalizedDocs :: chunk_elements().

此函式可用於對 application/erlang+html 文件進行空白字元正規化。

連結至此函式

render(Module, Docs)

檢視原始碼 (自 OTP 23.0 起)
-spec render(Module, Docs) -> unicode:chardata() when Module :: module(), Docs :: docs_v1().

等同於 render(Module, Docs, #{})

連結至此函式

render(Module, DocsOrFunction, ConfigOrDocs)

檢視原始碼 (自 OTP 23.0 起)
-spec render(Module, Docs, Config) -> unicode:chardata()
                when Module :: module(), Docs :: docs_v1(), Config :: config();
            (Module, Function, Docs) -> Res
                when
                    Module :: module(),
                    Function :: atom(),
                    Docs :: docs_v1(),
                    Res :: unicode:chardata() | {error, function_missing}.

渲染模組或函式文件。

如果以 render(Module, Docs, Config) 呼叫,則會渲染模組文件。

如果以 render(Module, Function, Docs) 呼叫,則等同於 render(Module, Function, Docs, #{})

連結至此函式

render(Module, Function, DocsOrArity, ConfigOrDocs)

檢視原始碼 (自 OTP 23.0 起)
-spec render(Module, Function, Docs, Config) -> Res
                when
                    Module :: module(),
                    Function :: atom(),
                    Docs :: docs_v1(),
                    Config :: config(),
                    Res :: unicode:chardata() | {error, function_missing};
            (Module, Function, Arity, Docs) -> Res
                when
                    Module :: module(),
                    Function :: atom(),
                    Arity :: arity(),
                    Docs :: docs_v1(),
                    Res :: unicode:chardata() | {error, function_missing}.

渲染函式文件。

如果以 render(Module, Function, Docs, Config) 呼叫,則會渲染函式文件。

如果以 render(Module, Function, Arity, Docs) 呼叫,則等同於 render(Module, Function, Arity, Docs, #{})

連結至此函式

render(Module, Function, Arity, Docs, Config)

檢視原始碼 (自 OTP 23.2 起)
-spec render(Module, Function, Arity, Docs, Config) -> Res
                when
                    Module :: module(),
                    Function :: atom(),
                    Arity :: arity(),
                    Docs :: docs_v1(),
                    Config :: config(),
                    Res :: unicode:chardata() | {error, function_missing}.

渲染函式的文件。

連結至此函式

render_callback(Module, Docs)

檢視原始碼 (自 OTP 23.0 起)
-spec render_callback(Module, Docs) -> unicode:chardata() when Module :: module(), Docs :: docs_v1().

等同於 render_callback(Module, Docs, #{})

連結至此函式

render_callback(Module, DocsOrCallback, ConfigOrDocs)

檢視原始碼 (自 OTP 23.0 起)
-spec render_callback(Module, Docs, Config) -> unicode:chardata()
                         when Module :: module(), Docs :: docs_v1(), Config :: config();
                     (Module, Callback, Docs) -> Res
                         when
                             Module :: module(),
                             Callback :: atom(),
                             Docs :: docs_v1(),
                             Res :: unicode:chardata() | {error, callback_missing}.

渲染模組中的所有回呼或回呼文件。

如果以 render_callback(Module, Docs, Config) 呼叫,則會渲染包含所有回呼的清單。

如果以 render_callback(Module, Callback, Docs) 呼叫,則等同於 render_callback(Module, Callback, Docs, #{})

連結至此函式

render_callback(Module, Callback, DocsOrArity, ConfigOrDocs)

檢視原始碼 (自 OTP 23.0 起)
-spec render_callback(Module, Callback, Docs, Config) -> Res
                         when
                             Module :: module(),
                             Callback :: atom(),
                             Docs :: docs_v1(),
                             Config :: config(),
                             Res :: unicode:chardata() | {error, callback_missing};
                     (Module, Callback, Arity, Docs) -> Res
                         when
                             Module :: module(),
                             Callback :: atom(),
                             Arity :: arity(),
                             Docs :: docs_v1(),
                             Res :: unicode:chardata() | {error, callback_missing}.

渲染回呼文件。

如果以 render_callback(Module, Callback, Docs, Config) 呼叫,則會渲染回呼文件。

如果以 render_callback(Module, Callback, Arity, Docs) 呼叫,則等同於 render_callback(Module, Callback, Arity, Docs, #{})

連結至此函式

render_callback(Module, Callback, Arity, Docs, Config)

檢視原始碼 (自 OTP 23.2 起)
-spec render_callback(Module, Callback, Arity, Docs, Config) -> Res
                         when
                             Module :: module(),
                             Callback :: atom(),
                             Arity :: arity(),
                             Docs :: docs_v1(),
                             Config :: config(),
                             Res :: unicode:chardata() | {error, callback_missing}.

渲染模組中回呼的文件。

連結至此函式

render_type(Module, Docs)

檢視原始碼 (自 OTP 23.0 起)
-spec render_type(Module, Docs) -> unicode:chardata() when Module :: module(), Docs :: docs_v1().

等同於 render_type(Module, Docs, #{})

連結至此函式

render_type(Module, DocsOrType, ConfigOrDocs)

檢視原始碼 (自 OTP 23.0 起)
-spec render_type(Module, Docs, Config) -> unicode:chardata()
                     when Module :: module(), Docs :: docs_v1(), Config :: config();
                 (Module, Type, Docs) -> Res
                     when
                         Module :: module(),
                         Type :: atom(),
                         Docs :: docs_v1(),
                         Res :: unicode:chardata() | {error, type_missing}.

渲染模組中的所有類型或類型文件。

如果以 render_type(Module, Docs, Config) 呼叫,則會渲染包含所有類型的清單。

如果以 render_type(Module, Type, Docs) 呼叫,則等同於 render_type(Module, Type, Docs, #{})

連結至此函式

render_type(Module, Type, DocsOrArity, ConfigOrDocs)

檢視原始碼 (自 OTP 23.0 起)
-spec render_type(Module, Type, Docs, Config) -> Res
                     when
                         Module :: module(),
                         Type :: atom(),
                         Docs :: docs_v1(),
                         Config :: config(),
                         Res :: unicode:chardata() | {error, type_missing};
                 (Module, Type, Arity, Docs) -> Res
                     when
                         Module :: module(),
                         Type :: atom(),
                         Arity :: arity(),
                         Docs :: docs_v1(),
                         Res :: unicode:chardata() | {error, type_missing}.

渲染類型文件。

如果以 render_type(Module, Type, Docs, Config) 呼叫,則會渲染類型文件。

如果以 render_type(Module, Type, Arity, Docs) 呼叫,則等同於 render_type(Module, Type, Arity, Docs, #{})

連結至此函式

render_type(Module, Type, Arity, Docs, Config)

檢視原始碼 (自 OTP 23.2 起)
-spec render_type(Module, Type, Arity, Docs, Config) -> Res
                     when
                         Module :: module(),
                         Type :: atom(),
                         Arity :: arity(),
                         Docs :: docs_v1(),
                         Config :: config(),
                         Res :: unicode:chardata() | {error, type_missing}.

渲染模組中類型的文件。

連結至此函式

supported_tags()

檢視原始碼 (自 OTP 24.0 起)
-spec supported_tags() -> [chunk_element_type()].

此函式可用於找出 application/erlang+html 文件支援哪些標籤。

連結至此函式

validate(Module)

檢視原始碼 (自 OTP 23.0 起)
-spec validate(Module) -> ok when Module :: module() | docs_v1().

此函式可用於對 application/erlang+html 格式的文件內容進行基本驗證。