Parcourir la source

Fix code block highlight

Qian Linfeng il y a 9 ans
Parent
commit
47a6458996

+ 5 - 5
docs/source/bridge.rst

@@ -33,7 +33,7 @@ Create a bridge that forwards all the 'sensor/#' messages from emqttd1 to emqttd
 1. Start Brokers
 ................
 
-.. code:: console
+.. code-block:: bash
 
     cd emqttd1/ && ./bin/emqttd start
     cd emqttd2/ && ./bin/emqttd start
@@ -41,7 +41,7 @@ Create a bridge that forwards all the 'sensor/#' messages from emqttd1 to emqttd
 2. Create bridge: emqttd1--sensor/#-->emqttd2
 .............................................
 
-.. code:: console
+.. code-block:: bash
 
     $ cd emqttd1 && ./bin/emqttd_ctl bridges start emqttd2@127.0.0.1 sensor/#
 
@@ -54,7 +54,7 @@ Create a bridge that forwards all the 'sensor/#' messages from emqttd1 to emqttd
 3. Test the bridge
 ...................
 
-.. code:: console
+.. code-block:: bash
 
     #emqttd2
     mosquitto_sub -t sensor/# -p 2883 -d
@@ -65,7 +65,7 @@ Create a bridge that forwards all the 'sensor/#' messages from emqttd1 to emqttd
 4. Delete the bridge
 .....................
 
-.. code:: console
+.. code-block:: bash
 
     ./bin/emqttd_ctl bridges stop emqttd2@127.0.0.1 sensor/#
 
@@ -73,7 +73,7 @@ Create a bridge that forwards all the 'sensor/#' messages from emqttd1 to emqttd
 emqttd Bridge CLI
 -----------------
 
-.. code:: console
+.. code-block:: bash
 
     #query bridges
     ./bin/emqttd_ctl bridges list

+ 1 - 1
docs/source/changes.rst

@@ -343,7 +343,7 @@ Benchmark
 
 3.1G memory and 50+ CPU/core:
 
-.. code:: console
+.. code-block:: bash
 
     Connections: 250K
     Subscribers: 250K

+ 7 - 7
docs/source/cluster.rst

@@ -31,7 +31,7 @@ An erlang runtime system called 'node' is identified by a unique name like email
 
 Suppose we start four Erlang nodes on localhost:
 
-.. code:: console
+.. code-block:: bash
 
     erl -name node1@127.0.0.1
     erl -name node2@127.0.0.1
@@ -54,7 +54,7 @@ epmd
 
 epmd(Erlang Port Mapper Daemon) is a daemon service that is responsible for mapping node names to machine addresses(TCP sockets). The daemon is started automatically on every host where an Erlang node started.
 
-.. code:: console
+.. code-block:: bash
 
     (node1@127.0.0.1)6> net_adm:names().
     {ok,[{"node1",62740},
@@ -79,7 +79,7 @@ Cluster Design
 
 The cluster architecture of emqttd broker is based on distrubuted Erlang/OTP and Mnesia database.
 
-The cluster design could be summarized by the following two rules::
+The cluster design could be summarized by the following two rules:
 
 1. When a MQTT client SUBSCRIBE a Topic on a node, the node will tell all the other nodes in the cluster: I subscribed a Topic.
 
@@ -94,7 +94,7 @@ Finally there will be a global route table(Topic -> Node) that replicated to all
 Topic Trie and Route Table
 --------------------------
 
-Every node in the cluster will store a topic trie and route table in mnesia database. 
+Every node in the cluster will store a topic trie and route table in mnesia database.
 
 Suppose that we create subscriptions:
 
@@ -242,7 +242,9 @@ The Firewall
 
 If there is a firewall between clustered nodes, the cluster requires to open 4369 port used by epmd daemon, and a port segment for nodes' communication.
 
-Configure the port segment in etc/emqttd.config, for example::
+Configure the port segment in etc/emqttd.config, for example:
+
+.. code-block:: erlang
 
     [{kernel, [
         ...
@@ -268,5 +270,3 @@ Consistent Hash and DHT
 -----------------------
 
 Consistent Hash and DHT are popular in the design of NoSQL databases. Cluster of emqttd broker could support 10 million size of global routing table now. We could use the Consistent Hash or DHT to partition the routing table, and evolve the cluster to larger size.
-
-

+ 54 - 33
docs/source/config.rst

@@ -86,7 +86,7 @@ The two most important parameters in etc/vm.args:
 
 +-------+---------------------------------------------------------------------------+
 | +P    | Max number of Erlang proccesses. A MQTT client consumes two proccesses.   |
-|       | The value should be larger than max_clients * 2                           | 
+|       | The value should be larger than max_clients * 2                           |
 +-------+---------------------------------------------------------------------------+
 | +Q    | Max number of Erlang Ports. A MQTT client consumes one port.              |
 |       | The value should be larger than max_clients.                              |
@@ -110,7 +110,7 @@ File Syntax
 
 The file users the standard Erlang config syntax, consists of a list of erlang applications and their environments.
 
-.. code:: erlang
+.. code-block:: erlang
 
     [{kernel, [
         {start_timer, true},
@@ -136,13 +136,17 @@ The file adopts Erlang Term Syntax:
 Log Level and File
 ------------------
 
-Logger of emqttd broker is implemented by 'lager' application::
+Logger of emqttd broker is implemented by 'lager' application:
+
+.. code-block:: erlang
 
   {lager, [
     ...
   ]},
 
-Configure log handlers::
+Configure log handlers:
+
+.. code-block:: erlang
 
     {handlers, [
         {lager_console_backend, info},
@@ -169,7 +173,9 @@ Configure log handlers::
 emqttd Application
 ------------------
 
-The MQTT broker is implemented by erlang 'emqttd' application::
+The MQTT broker is implemented by erlang 'emqttd' application:
+
+.. code-block:: erlang
 
  {emqttd, [
     %% Authentication and Authorization
@@ -208,14 +214,16 @@ Pluggable Authentication
 
 The emqttd broker supports pluggable authentication mechanism with a list of modules and plugins.
 
-The broker provides Username, ClientId, LDAP and anonymous authentication modules by default::
+The broker provides Username, ClientId, LDAP and anonymous authentication modules by default:
+
+.. code-block:: erlang
 
     %% Authetication. Anonymous Default
     {auth, [
         %% Authentication with username, password
         %% Add users: ./bin/emqttd_ctl users add Username Password
         %% {username, [{"test", "public"}]},
-        
+
         %% Authentication with clientid
         % {clientid, [{password, no}, {file, "etc/clients.config"}]},
 
@@ -235,7 +243,7 @@ The broker provides Username, ClientId, LDAP and anonymous authentication module
         {anonymous, []}
     ]},
 
-The modules enabled at the same time compose an authentication chain:
+The modules enabled at the same time compose an authentication chain::
 
                ----------------           ----------------           -------------
     Client --> |   Username   | -ignore-> |   ClientID   | -ignore-> | Anonymous |
@@ -243,13 +251,13 @@ The modules enabled at the same time compose an authentication chain:
                       |                         |                         |
                      \|/                       \|/                       \|/
                 allow | deny              allow | deny              allow | deny
- 
+
 .. NOTE:: There are also MySQL、PostgreSQL、Redis、MongoDB Authentication Plugins.
 
 Username Authentication
 .......................
 
-.. code:: erlang
+.. code-block:: erlang
 
     {username, [{client1, "passwd1"}, {client2, "passwd2"}]},
 
@@ -266,7 +274,7 @@ Two ways to configure users:
 ClientID Authentication
 .......................
 
-.. code:: erlang
+.. code-block:: erlang
 
     {clientid, [{password, no}, {file, "etc/clients.config"}]},
 
@@ -279,7 +287,7 @@ Configure ClientIDs in etc/clients.config::
 LDAP Authentication
 ...................
 
-.. code:: erlang
+.. code-block:: erlang
 
     {ldap, [
        {servers, ["localhost"]},
@@ -304,7 +312,9 @@ Allow any client to connect to the broker::
 ACL
 ---
 
-Enable the default ACL module::
+Enable the default ACL module:
+
+.. code-block:: erlang
 
     {acl, [
         %% Internal ACL module
@@ -314,7 +324,7 @@ Enable the default ACL module::
 MQTT Packet and ClientID
 ------------------------
 
-.. code::
+.. code-block:: erlang
 
     {packet, [
 
@@ -328,7 +338,7 @@ MQTT Packet and ClientID
 MQTT Client Idle Timeout
 ------------------------
 
-.. code::
+.. code-block:: erlang
 
     {client, [
         %% Socket is connected, but no 'CONNECT' packet received
@@ -338,7 +348,7 @@ MQTT Client Idle Timeout
 MQTT Session
 ------------
 
-.. code::
+.. code-block:: erlang
 
     {session, [
         %% Max number of QoS 1 and 2 messages that can be “in flight” at one time.
@@ -388,7 +398,9 @@ The message queue of session stores:
 
 2. Pending messages for inflight window is full
 
-Queue parameters::
+Queue parameters:
+
+.. code-block:: erlang
 
     {queue, [
         %% simple | priority
@@ -428,7 +440,7 @@ Queue parameters::
 Sys Interval of Broker
 -----------------------
 
-.. code::
+.. code-block:: erlang
 
     %% System interval of publishing $SYS messages
     {sys_interval, 60},
@@ -436,7 +448,7 @@ Sys Interval of Broker
 Retained messages
 -----------------
 
-.. code::
+.. code-block:: erlang
 
     {retained, [
         %% Expired after seconds, never expired if 0
@@ -452,12 +464,12 @@ Retained messages
 PubSub and Router
 -----------------
 
-.. code:: erlang
+.. code-block:: erlang
 
     {pubsub, [
         %% PubSub Pool
         {pool_size, 8},
-        
+
         %% Subscription: true | false
         {subscription, true},
 
@@ -468,7 +480,7 @@ PubSub and Router
 Bridge Parameters
 -----------------
 
-.. code:: erlang
+.. code-block:: erlang
 
     {bridge, [
         %% Bridge Queue Size
@@ -484,9 +496,11 @@ Enable Modules
 
 'presence' module will publish presence message to $SYS topic when a client connected or disconnected::
 
-        {presence, [{qos, 0}]},
+    {presence, [{qos, 0}]},
 
-'subscription' module forces the client to subscribe some topics when connected to the broker::
+'subscription' module forces the client to subscribe some topics when connected to the broker:
+
+.. code-block:: erlang
 
         %% Subscribe topics automatically when client connected
         {subscription, [
@@ -500,7 +514,9 @@ Enable Modules
             {"$Q/client/$c", 1}
         ]}
 
-'rewrite' module supports to rewrite the topic path::
+'rewrite' module supports to rewrite the topic path:
+
+.. code-block:: erlang
 
         %% Rewrite rules
         {rewrite, [{file, "etc/rewrite.config"}]}
@@ -508,7 +524,7 @@ Enable Modules
 Plugins Folder
 --------------
 
-.. code:: erlang
+.. code-block:: erlang
 
     {plugins, [
         %% Plugin App Library Dir
@@ -536,7 +552,7 @@ The TCP Ports occupied by emqttd broker by default:
 | 8083      | MQTT(WebSocket), HTTP API Port    |
 +-----------+-----------------------------------+
 
-.. code:: erlang
+.. code-block:: erlang
 
     {listeners, [
 
@@ -641,7 +657,9 @@ Listener Parameters:
 etc/acl.config
 --------------
 
-The 'etc/acl.config' is the default ACL config for emqttd broker. The rules by default::
+The 'etc/acl.config' is the default ACL config for emqttd broker. The rules by default:
+
+.. code-block:: erlang
 
     %% Allow 'dashboard' to subscribe '$SYS/#'
     {allow, {user, "dashboard"}, subscribe, ["$SYS/#"]}.
@@ -657,21 +675,23 @@ The 'etc/acl.config' is the default ACL config for emqttd broker. The rules by d
 
 An ACL rule is an Erlang tuple. The Access control module of emqttd broker matches the rule one by one from top to bottom::
 
-              ---------              ---------              ---------   
+              ---------              ---------              ---------
     Client -> | Rule1 | --nomatch--> | Rule2 | --nomatch--> | Rule3 | --> Default
               ---------              ---------              ---------
                   |                      |                      |
                 match                  match                  match
                  \|/                    \|/                    \|/
             allow | deny           allow | deny           allow | deny
-                
+
 .. _config_rewrite:
 
 ------------------
 etc/clients.config
 ------------------
 
-Enable ClientId Authentication in 'etc/emqttd.config'::
+Enable ClientId Authentication in 'etc/emqttd.config':
+
+.. code-block:: erlang
 
     {auth, [
         %% Authentication with clientid
@@ -688,7 +708,9 @@ Configure all allowed ClientIDs, IP Addresses in etc/clients.config::
 etc/rewrite.config
 ------------------
 
-The Rewrite Rules for emqttd_mod_rewrite::
+The Rewrite Rules for emqttd_mod_rewrite:
+
+.. code-block:: erlang
 
     {topic, "x/#", [
         {rewrite, "^x/y/(.+)$", "z/y/$1"},
@@ -698,4 +720,3 @@ The Rewrite Rules for emqttd_mod_rewrite::
     {topic, "y/+/z/#", [
         {rewrite, "^y/(.+)/z/(.+)$", "y/z/$2"}
     ]}.
-

+ 25 - 16
docs/source/design.rst

@@ -32,19 +32,19 @@ System Layers
 -------------
 
 1. Connection Layer
-   
+
    Handle TCP and WebSocket connections, encode/decode MQTT packets.
 
 2. Session Layer
-   
+
    Process MQTT PUBLISH/SUBSCRIBE Packets received from client, and deliver MQTT messages to client.
-   
+
 3. PubSub Layer
-   
+
    Dispatch MQTT messages to subscribers in a node.
 
 4. Routing(Distributed) Layer
-   
+
    Route MQTT messages among clustered nodes.
 
 ----------------
@@ -93,7 +93,7 @@ A MQTT session will store the subscriptions and inflight messages in memory:
 
 1. The Client’s subscriptions.
 
-2. Inflight qos1/2 messages sent to the client but unacked, QoS 2 messages which 
+2. Inflight qos1/2 messages sent to the client but unacked, QoS 2 messages which
    have been sent to the Client, but have not been completely acknowledged.
 
 3. Inflight qos2 messages received from client and waiting for PUBREL. QoS 2
@@ -191,7 +191,9 @@ Authentication and ACL
 
 The emqttd broker supports an extensible authentication/ACL mechanism, which is implemented by emqttd_access_control, emqttd_auth_mod and emqttd_acl_mod modules.
 
-emqttd_access_control module provides two APIs that help register/unregister auth or ACL module::
+emqttd_access_control module provides two APIs that help register/unregister auth or ACL module:
+
+.. code-block:: erlang
 
     register_mod(auth | acl, atom(), list()) -> ok | {error, any()}.
 
@@ -200,7 +202,9 @@ emqttd_access_control module provides two APIs that help register/unregister aut
 Authentication Bahaviour
 -------------------------
 
-The emqttd_auth_mod defines an Erlang behaviour for authentication module::
+The emqttd_auth_mod defines an Erlang behaviour for authentication module:
+
+.. code-block:: erlang
 
     -module(emqttd_auth_mod).
 
@@ -243,7 +247,9 @@ The authentication modules implemented by default:
 Authorization(ACL)
 ------------------
 
-The emqttd_acl_mod defines an Erlang behavihour for ACL module::
+The emqttd_acl_mod defines an Erlang behavihour for ACL module:
+
+.. code-block:: erlang
 
     -module(emqttd_acl_mod).
 
@@ -273,7 +279,9 @@ The emqttd_acl_mod defines an Erlang behavihour for ACL module::
 
     -endif.
 
-emqttd_acl_internal implements the default ACL based on etc/acl.config file::
+emqttd_acl_internal implements the default ACL based on etc/acl.config file:
+
+.. code-block:: erlang
 
     %%%-----------------------------------------------------------------------------
     %%%
@@ -360,7 +368,7 @@ Hook Implementation
 
 The hook APIs defined in emqttd module:
 
-.. code:: erlang
+.. code-block:: erlang
 
     -module(emqttd).
 
@@ -376,7 +384,7 @@ The hook APIs defined in emqttd module:
 
 And implemented in emqttd_hook module:
 
-.. code:: erlang
+.. code-block:: erlang
 
     -module(emqttd_hook).
 
@@ -398,12 +406,12 @@ Hook Usage
 
 The `emqttd_plugin_template`_ project provides the examples for hook usage:
 
-.. code:: erlang
+.. code-block:: erlang
 
     -module(emqttd_plugin_template).
 
     -export([load/1, unload/0]).
-    
+
     -export([on_message_publish/2, on_message_delivered/3, on_message_acked/3]).
 
     load(Env) ->
@@ -439,7 +447,9 @@ Plugin is a normal erlang application that can be started/stopped dynamically by
 emqttd_plugins Module
 ---------------------
 
-The plugin mechanism is implemented by emqttd_plugins module::
+The plugin mechanism is implemented by emqttd_plugins module:
+
+.. code-block:: erlang
 
     -module(emqttd_plugins).
 
@@ -468,4 +478,3 @@ http://github.com/emqtt/emqttd_plugin_template
 .. _eSockd: https://github.com/emqtt/esockd
 .. _Chain-of-responsibility_pattern: https://en.wikipedia.org/wiki/Chain-of-responsibility_pattern
 .. _emqttd_plugin_template: https://github.com/emqtt/emqttd_plugin_template/blob/master/src/emqttd_plugin_template.erl
-

+ 14 - 9
docs/source/getstarted.rst

@@ -61,7 +61,7 @@ Download binary package from: http://emqtt.io/downloads.
 
 Installing on Mac, for example:
 
-.. code:: console
+.. code-block:: bash
 
     unzip emqttd-macosx-0.16.0-beta-20160216.zip && cd emqttd
 
@@ -79,7 +79,7 @@ Installing from Source
 
 .. NOTE:: emqttd broker requires Erlang R17+ to build.
 
-.. code:: console
+.. code-block:: bash
 
     git clone https://github.com/emqtt/emqttd.git
 
@@ -132,7 +132,9 @@ Modules
 
 Configure the 'auth', 'module' paragraph in 'etc/emqttd.config' to enable a module.
 
-Enable 'emqttd_auth_username' module::
+Enable 'emqttd_auth_username' module:
+
+.. code-block:: erlang
 
     {access, [
         %% Authetication. Anonymous Default
@@ -142,7 +144,9 @@ Enable 'emqttd_auth_username' module::
 
             ...
 
-Enable 'emqttd_mod_presence' module::
+Enable 'emqttd_mod_presence' module:
+
+.. code-block:: erlang
 
     {modules, [
         %% Client presence management module.
@@ -195,7 +199,7 @@ We need tune the OS Kernel, TCP Stack, Erlang VM and emqttd broker for one milli
 Linux Kernel Parameters
 -----------------------
 
-.. code::
+.. code-block:: bash
 
     # 2M:
     sysctl -w fs.file-max=2097152
@@ -208,7 +212,7 @@ Linux Kernel Parameters
 TCP Stack Parameters
 --------------------
 
-.. code::
+.. code-block:: bash
 
     # backlog
     sysctl -w net.core.somaxconn=65536
@@ -232,7 +236,9 @@ emqttd/etc/vm.args::
 emqttd broker
 -------------
 
-emqttd/etc/emqttd.config::
+emqttd/etc/emqttd.config:
+
+.. code-block:: erlang
 
         {mqtt, 1883, [
             %% Size of acceptor pool
@@ -254,7 +260,7 @@ emqttd/etc/emqttd.config::
 Test Client
 -----------
 
-.. code::
+.. code-block:: bash
 
     sysctl -w net.ipv4.ip_local_port_range="500 65535"
     echo 1000000 > /proc/sys/fs/nr_open
@@ -290,4 +296,3 @@ GitHub: https://github.com/emqtt
 .. _emqttd_stomp:           https://github.com/emqtt/emqttd_stomp
 .. _emqttd_sockjs:          https://github.com/emqtt/emqttd_sockjs
 .. _emqttd_recon:           https://github.com/emqtt/emqttd_recon
-

+ 60 - 29
docs/source/guide.rst

@@ -13,7 +13,9 @@ The emqttd broker supports to authenticate MQTT clients with ClientID, Username/
 
 The authentication is provided by a list of extended modules, or MySQL, PostgreSQL and Redis Plugins.
 
-Enable an authentication module in etc/emqttd.config::
+Enable an authentication module in etc/emqttd.config:
+
+.. code-block:: erlang
 
     %% Authentication and Authorization
     {access, [
@@ -21,7 +23,7 @@ Enable an authentication module in etc/emqttd.config::
         {auth, [
             %% Authentication with username, password
             %{username, []},
-            
+
             %% Authentication with clientid
             %{clientid, [{password, no}, {file, "etc/clients.config"}]},
 
@@ -86,7 +88,7 @@ Two ways to add users:
 ClientId
 --------
 
-.. code:: erlang
+.. code-block:: erlang
 
     {clientid, [{password, no}, {file, "etc/clients.config"}]},
 
@@ -99,7 +101,7 @@ Configure ClientIDs in etc/clients.config::
 LDAP
 ----
 
-.. code:: erlang
+.. code-block:: erlang
 
     {ldap, [
        {servers, ["localhost"]},
@@ -122,7 +124,9 @@ Allow any client to connect to the broker::
 MySQL
 -----
 
-Authenticate against MySQL database. Support we create a mqtt_user table::
+Authenticate against MySQL database. Support we create a mqtt_user table:
+
+.. code-block:: sql
 
     CREATE TABLE `mqtt_user` (
       `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
@@ -134,7 +138,9 @@ Authenticate against MySQL database. Support we create a mqtt_user table::
       UNIQUE KEY `mqtt_username` (`username`)
     ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
-Configure the 'authquery' and 'password_hash' in emqttd_plugin_mysql/etc/plugin.config::
+Configure the 'authquery' and 'password_hash' in emqttd_plugin_mysql/etc/plugin.config:
+
+.. code-block:: erlang
 
     [
 
@@ -161,7 +167,9 @@ Load the plugin::
 PostgreSQL
 ----------
 
-Authenticate against PostgreSQL database. Create a mqtt_user table::
+Authenticate against PostgreSQL database. Create a mqtt_user table:
+
+.. code-block:: sql
 
     CREATE TABLE mqtt_user (
       id SERIAL primary key,
@@ -170,7 +178,9 @@ Authenticate against PostgreSQL database. Create a mqtt_user table::
       salt character varying(40)
     );
 
-Configure the 'authquery' and 'password_hash' in emqttd_plugin_pgsql/etc/plugin.config::
+Configure the 'authquery' and 'password_hash' in emqttd_plugin_pgsql/etc/plugin.config:
+
+.. code-block:: erlang
 
     [
 
@@ -183,7 +193,7 @@ Configure the 'authquery' and 'password_hash' in emqttd_plugin_pgsql/etc/plugin.
 
         %% hash algorithm: md5, sha, sha256, pbkdf2?
         {password_hash, sha256},
-        
+
         ...
 
       ]}
@@ -198,7 +208,9 @@ Redis
 
 Authenticate against Redis. MQTT users could be stored in redis HASH, the key is "mqtt_user:<Username>".
 
-Configure 'authcmd' and 'password_hash' in emqttd_plugin_redis/etc/plugin.config::
+Configure 'authcmd' and 'password_hash' in emqttd_plugin_redis/etc/plugin.config:
+
+.. code-block:: erlang
 
     [
       {emqttd_plugin_redis, [
@@ -232,7 +244,7 @@ The ACL rules define::
 
 Access Control Module of emqttd broker will match the rules one by one::
 
-              ---------              ---------              ---------   
+              ---------              ---------              ---------
     Client -> | Rule1 | --nomatch--> | Rule2 | --nomatch--> | Rule3 | --> Default
               ---------              ---------              ---------
                   |                      |                      |
@@ -245,14 +257,18 @@ Internal
 
 The default ACL of emqttd broker is implemented by an 'internal' module.
 
-Enable the 'internal' ACL module in etc/emqttd.config::
+Enable the 'internal' ACL module in etc/emqttd.config:
+
+.. code-block:: erlang
 
     {acl, [
         %% Internal ACL module
         {internal,  [{file, "etc/acl.config"}, {nomatch, allow}]}
     ]}
 
-The ACL rules of 'internal' module are defined in 'etc/acl.config' file::
+The ACL rules of 'internal' module are defined in 'etc/acl.config' file:
+
+.. code-block:: erlang
 
     %% Allow 'dashboard' to subscribe '$SYS/#'
     {allow, {user, "dashboard"}, subscribe, ["$SYS/#"]}.
@@ -269,7 +285,9 @@ The ACL rules of 'internal' module are defined in 'etc/acl.config' file::
 MySQL
 -----
 
-ACL against MySQL database. The mqtt_acl table and default data::
+ACL against MySQL database. The mqtt_acl table and default data:
+
+.. code-block:: sql
 
     CREATE TABLE `mqtt_acl` (
       `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
@@ -291,7 +309,9 @@ ACL against MySQL database. The mqtt_acl table and default data::
         (6,1,'127.0.0.1',NULL,NULL,2,'#'),
         (7,1,NULL,'dashboard',NULL,1,'$SYS/#');
 
-Configure 'aclquery' and 'acl_nomatch' in emqttd_plugin_mysql/etc/plugin.config::
+Configure 'aclquery' and 'acl_nomatch' in emqttd_plugin_mysql/etc/plugin.config:
+
+.. code-block:: erlang
 
     [
 
@@ -311,7 +331,9 @@ Configure 'aclquery' and 'acl_nomatch' in emqttd_plugin_mysql/etc/plugin.config:
 PostgreSQL
 ----------
 
-ACL against PostgreSQL database. The mqtt_acl table and default data::
+ACL against PostgreSQL database. The mqtt_acl table and default data:
+
+.. code-block:: sql
 
     CREATE TABLE mqtt_acl (
       id SERIAL primary key,
@@ -332,7 +354,9 @@ ACL against PostgreSQL database. The mqtt_acl table and default data::
         (6,1,'127.0.0.1',NULL,NULL,2,'#'),
         (7,1,NULL,'dashboard',NULL,1,'$SYS/#');
 
-Configure 'aclquery' and 'acl_nomatch' in emqttd_plugin_pgsql/etc/plugin.config::
+Configure 'aclquery' and 'acl_nomatch' in emqttd_plugin_pgsql/etc/plugin.config:
+
+.. code-block:: erlang
 
     [
 
@@ -357,7 +381,9 @@ Redis
 
 ACL against Redis. We store ACL rules for each MQTT client in a Redis List by defualt. The key is "mqtt_acl:<Username>", the value is a list of "publish <Topic>", "subscribe <Topic>" or "pubsub <Topic>".
 
-Configure 'aclcmd' and 'acl_nomatch' in emqttd_plugin_redis/etc/plugin.config::
+Configure 'aclcmd' and 'acl_nomatch' in emqttd_plugin_redis/etc/plugin.config:
+
+.. code-block:: erlang
 
     [
       {emqttd_plugin_redis, [
@@ -394,7 +420,9 @@ For example, we use mosquitto_sub/pub commands::
 
 MQTT V3.1.1 Protocol Specification: http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/mqtt-v3.1.1.html
 
-MQTT Listener of emqttd broker is configured in etc/emqttd.config::
+MQTT Listener of emqttd broker is configured in etc/emqttd.config:
+
+.. code-block:: erlang
 
         {mqtt, 1883, [
             %% Size of acceptor pool
@@ -423,7 +451,9 @@ MQTT Listener of emqttd broker is configured in etc/emqttd.config::
             ]}
         ]},
 
-MQTT(SSL) Listener, Default Port is 8883::
+MQTT(SSL) Listener, Default Port is 8883:
+
+.. code-block:: erlang
 
         {mqtts, 8883, [
             %% Size of acceptor pool
@@ -492,7 +522,9 @@ The Dashboard plugin provides a test page for WebSocket::
 
     http://127.0.0.1:18083/websocket.html
 
-Listener of WebSocket and HTTP Publish API is configured in etc/emqttd.config::
+Listener of WebSocket and HTTP Publish API is configured in etc/emqttd.config:
+
+.. code-block:: erlang
 
     %% HTTP and WebSocket Listener
     {http, 8083, [
@@ -525,7 +557,7 @@ For emqttd broker is clustered, the $SYS topic path is started with::
 
     $SYS/brokers/emqttd@host2/uptime
 
-.. NOTE:: The broker only allows clients from localhost to subscribe $SYS topics by default. 
+.. NOTE:: The broker only allows clients from localhost to subscribe $SYS topics by default.
 
 Sys Interval of publishing $SYS messages, could be configured in etc/emqttd.config::
 
@@ -569,11 +601,11 @@ The topic path started with: $SYS/brokers/${node}/clients/
 
 Properties of 'connected' Payload::
 
-    ipaddress: "127.0.0.1", 
-    username:  "test", 
-    session:   false, 
-    protocol:  3, 
-    connack:   0, 
+    ipaddress: "127.0.0.1",
+    username:  "test",
+    session:   false,
+    protocol:  3,
+    connack:   0,
     ts:        1432648482
 
 Properties of 'disconnected' Payload::
@@ -614,7 +646,7 @@ Subscriptions
 +---------------------+---------------------------------------------+
 | Topic               | Description                                 |
 +---------------------+---------------------------------------------+
-| subscriptions/count | Count of current subscriptions              | 
+| subscriptions/count | Count of current subscriptions              |
 +---------------------+---------------------------------------------+
 | subscriptions/max   | Max number of subscriptions                 |
 +---------------------+---------------------------------------------+
@@ -756,4 +788,3 @@ Stop a Trace::
 .. _emqttd_plugin_mysql:    https://github.com/emqtt/emqttd_plugin_mysql
 .. _emqttd_plugin_pgsql:    https://github.com/emqtt/emqttd_plugin_pgsql
 .. _emqttd_plugin_redis:    https://github.com/emqtt/emqttd_plugin_redis
-

+ 10 - 10
docs/source/install.rst

@@ -45,19 +45,19 @@ Installing on Linux
 
 Download CentOS Package from: http://emqtt.io/downloads/centos, and then unzip:
 
-.. code:: console
+.. code-block:: bash
 
     unzip emqttd-centos64-0.16.0-beta-20160216.zip
 
 Start the broker in console mode:
 
-.. code:: console
+.. code-block:: bash
 
     cd emqttd && ./bin/emqttd console
 
 If the broker is started successfully, console will print:
 
-.. code:: console
+.. code-block:: bash
 
     starting emqttd on node 'emqttd@127.0.0.1'
     emqttd ctl is starting...[done]
@@ -88,7 +88,7 @@ CTRL+C to close the console and stop the broker.
 
 Start the broker in daemon mode:
 
-.. code:: console
+.. code-block:: bash
 
     ./bin/emqttd start
 
@@ -96,7 +96,7 @@ The boot logs in log/emqttd_sasl.log file.
 
 Check the running status of the broker:
 
-.. code:: console
+.. code-block:: bash
 
     $ ./bin/emqttd_ctl status
     Node 'emqttd@127.0.0.1' is started
@@ -132,7 +132,7 @@ Download Mac Package from: http://emqtt.io/downloads/macosx
 
 Configure 'lager' log level in 'etc/emqttd.config', all MQTT messages recevied/sent will be printed on console:
 
-.. code:: erlang
+.. code-block:: erlang
 
     {lager, [
         ...
@@ -196,7 +196,7 @@ Could use apt-get on Ubuntu, yum on CentOS/RedHat and brew on Mac to install Erl
 
 When all dependencies are ready, clone the emqttd project from github.com and build:
 
-.. code:: console
+.. code-block:: bash
 
     git clone https://github.com/emqtt/emqttd.git
 
@@ -226,7 +226,7 @@ TCP Ports Used
 
 The TCP ports used can be configured in etc/emqttd.config:
 
-.. code:: erlang
+.. code-block:: erlang
 
     {listeners, [
         {mqtt, 1883, [
@@ -275,7 +275,7 @@ Two important parameters in etc/vm.args:
 
 The maximum number of allowed MQTT clients:
 
-.. code:: erlang
+.. code-block:: erlang
 
     {listeners, [
         {mqtt, 1883, [
@@ -295,7 +295,7 @@ The maximum number of allowed MQTT clients:
 /etc/init.d/emqttd
 -------------------
 
-.. code:: shell
+.. code-block:: bash
 
     #!/bin/sh
     #

+ 31 - 24
docs/source/plugins.rst

@@ -75,7 +75,9 @@ The Web Dashboard for emqttd broker. The plugin will be loaded automatically whe
 Configure Dashboard
 -------------------
 
-emqttd_dashboard/etc/plugin.config::
+emqttd_dashboard/etc/plugin.config:
+
+.. code-block:: erlang
 
     [
       {emqttd_dashboard, [
@@ -100,7 +102,7 @@ MQTT Authentication, ACL with MySQL database.
 MQTT User Table
 ---------------
 
-.. code:: sql
+.. code-block:: sql
 
     CREATE TABLE `mqtt_user` (
       `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
@@ -115,7 +117,7 @@ MQTT User Table
 MQTT ACL Table
 --------------
 
-.. code:: sql
+.. code-block:: sql
 
     CREATE TABLE `mqtt_acl` (
       `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
@@ -132,7 +134,9 @@ MQTT ACL Table
 Configure emqttd_plugin_mysql/etc/plugin.config
 -----------------------------------------------
 
-Configure MySQL host, username, password and database::
+Configure MySQL host, username, password and database:
+
+.. code-block:: erlang
 
     [
 
@@ -178,7 +182,7 @@ Configure MySQL host, username, password and database::
 Load emqttd_plugin_mysql plugin
 -------------------------------
 
-.. code::
+.. code-block:: bash
 
     ./bin/emqttd_ctl plugins load emqttd_plugin_mysql
 
@@ -191,7 +195,7 @@ MQTT Authentication, ACL with PostgreSQL Database.
 MQTT User Table
 ---------------
 
-.. code:: sql
+.. code-block:: sql
 
     CREATE TABLE mqtt_user (
       id SERIAL primary key,
@@ -203,7 +207,7 @@ MQTT User Table
 MQTT ACL Table
 --------------
 
-.. code:: sql
+.. code-block:: sql
 
     CREATE TABLE mqtt_acl (
       id SERIAL primary key,
@@ -227,7 +231,9 @@ MQTT ACL Table
 Configure emqttd_plugin_pgsql/etc/plugin.config
 -----------------------------------------------
 
-Configure host, username, password and database of PostgreSQL::
+Configure host, username, password and database of PostgreSQL:
+
+.. code-block:: erlang
 
     [
 
@@ -274,7 +280,7 @@ Configure host, username, password and database of PostgreSQL::
 Load emqttd_plugin_pgsql Plugin
 -------------------------------
 
-.. code:: shell
+.. code-block:: bash
 
     ./bin/emqttd_ctl plugins load emqttd_plugin_pgsql
 
@@ -287,7 +293,7 @@ MQTT Authentication, ACL with Redis.
 Configure emqttd_plugin_redis/etc/plugin.config
 -----------------------------------------------
 
-.. code:: erlang
+.. code-block:: erlang
 
     [
       {emqttd_plugin_redis, [
@@ -331,7 +337,7 @@ Configure emqttd_plugin_redis/etc/plugin.config
 Load emqttd_plugin_redis Plugin
 -------------------------------
 
-.. code:: console
+.. code-block:: bash
 
     ./bin/emqttd_ctl plugins load emqttd_plugin_redis
 
@@ -346,7 +352,7 @@ Configure emqttd_stomp/etc/plugin.config
 
 .. NOTE:: Default Port for STOMP Protocol: 61613
 
-.. code:: erlang
+.. code-block:: erlang
 
     [
       {emqttd_stomp, [
@@ -378,7 +384,7 @@ Configure emqttd_stomp/etc/plugin.config
 Load emqttd_stomp Plugin
 ------------------------
 
-.. code::
+.. code-block:: bash
 
     ./bin/emqttd_ctl plugins load emqttd_stomp
 
@@ -394,7 +400,7 @@ emqttd_sockjs plugin enables web browser to connect to emqttd broker and communi
 Configure emqttd_sockjs
 -----------------------
 
-.. code:: erlang
+.. code-block:: erlang
 
     [
       {emqttd_sockjs, [
@@ -411,7 +417,7 @@ Load emqttd_sockjs Plugin
 
 .. NOTE:: emqttd_stomp Plugin required.
 
-.. code:: console
+.. code-block:: bash
 
     ./bin/emqttd_ctl plugins load emqttd_stomp
 
@@ -431,14 +437,14 @@ The plugin loads `recon`_ library on a running emqttd broker. Recon libray helps
 Load emqttd_recon Plugin
 ------------------------
 
-.. code:: console
+.. code-block:: bash
 
     ./bin/emqttd_ctl plugins load emqttd_recon
 
 Recon CLI
 ---------
 
-.. code:: console
+.. code-block:: bash
 
     ./bin/emqttd_ctl recon
 
@@ -473,7 +479,7 @@ Register Auth/ACL Modules
 
 emqttd_auth_demo.erl - demo authentication module:
 
-.. code:: erlang
+.. code-block:: erlang
 
     -module(emqttd_auth_demo).
 
@@ -494,7 +500,7 @@ emqttd_auth_demo.erl - demo authentication module:
 
 emqttd_acl_demo.erl - demo ACL module:
 
-.. code:: erlang
+.. code-block:: erlang
 
     -module(emqttd_acl_demo).
 
@@ -517,7 +523,7 @@ emqttd_acl_demo.erl - demo ACL module:
 
 emqttd_plugin_template_app.erl - Register the auth/ACL modules:
 
-.. code:: erlang
+.. code-block:: erlang
 
     ok = emqttd_access_control:register_mod(auth, emqttd_auth_demo, []),
     ok = emqttd_access_control:register_mod(acl, emqttd_acl_demo, []),
@@ -549,7 +555,9 @@ The plugin could register callbacks for hooks. The hooks will be run by the brok
 | client.disconnected    | Run when a client is disconnnected    |
 +------------------------+---------------------------------------+
 
-emqttd_plugin_template.erl for example::
+emqttd_plugin_template.erl for example:
+
+.. code-block:: erlang
 
     %% Called when the plugin application start
     load(Env) ->
@@ -568,7 +576,7 @@ Register CLI Modules
 
 emqttd_cli_demo.erl:
 
-.. code:: erlang
+.. code-block:: erlang
 
     -module(emqttd_cli_demo).
 
@@ -584,7 +592,7 @@ emqttd_cli_demo.erl:
 
 emqttd_plugin_template_app.erl - register the CLI module to emqttd broker:
 
-.. code:: erlang
+.. code-block:: erlang
 
     emqttd_ctl:register_cmd(cmd, {emqttd_cli_demo, cmd}, []).
 
@@ -602,4 +610,3 @@ There will be a new CLI after the plugin loaded::
 .. _emqttd_recon:           https://github.com/emqtt/emqttd_recon
 .. _emqttd_plugin_template: https://github.com/emqtt/emqttd_plugin_template
 .. _recon:                  http://ferd.github.io/recon/
-

+ 3 - 2
docs/source/tune.rst

@@ -106,7 +106,9 @@ Tuning and optimize the Erlang VM in etc/vm.args file::
 emqttd broker
 -------------
 
-Tune the acceptor pool, max_clients limit and sockopts for TCP listener in etc/emqttd.config::
+Tune the acceptor pool, max_clients limit and sockopts for TCP listener in etc/emqttd.config:
+
+.. code-block:: erlang
 
     {mqtt, 1883, [
         %% Size of acceptor pool
@@ -141,4 +143,3 @@ emqtt_benchmark
 ---------------
 
 Test tool for concurrent connections: http://github.com/emqtt/emqtt_benchmark
-