Enable strict/explicit code highlighting

This commit is contained in:
Mads Marquart
2019-07-03 23:42:32 +02:00
parent d279c96dd5
commit a9c681818a
5 changed files with 26 additions and 20 deletions

View File

@@ -1,5 +1,4 @@
.. currentmodule:: fbchat
.. highlight:: python
.. module:: fbchat
.. _api:
.. Note: we're using () to hide the __init__ method where relevant

View File

@@ -54,12 +54,7 @@ master_doc = "index"
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
rst_prolog = """
.. highlight:: python
.. currentmodule:: {}
""".format(
project
)
rst_prolog = ".. currentmodule:: " + project
# The reST default role (used for this markup: `text`) to use for all
# documents.
@@ -70,6 +65,10 @@ default_role = "any"
#
nitpicky = True
# Prefer strict Python highlighting
#
highlight_language = "python3"
# If true, '()' will be appended to :func: etc. cross-reference text.
#
add_function_parentheses = False

View File

@@ -1,4 +1,3 @@
.. highlight:: sh
.. _install:
Installation
@@ -7,7 +6,9 @@ Installation
Pip Install fbchat
------------------
To install fbchat, run this command::
To install fbchat, run this command:
.. code-block:: sh
$ pip install fbchat
@@ -21,16 +22,22 @@ Get the Source Code
fbchat is developed on GitHub, where the code is
`always available <https://github.com/carpedm20/fbchat>`_.
You can either clone the public repository::
You can either clone the public repository:
.. code-block:: sh
$ git clone git://github.com/carpedm20/fbchat.git
Or, download a `tarball <https://github.com/carpedm20/fbchat/tarball/master>`_::
Or, download a `tarball <https://github.com/carpedm20/fbchat/tarball/master>`_:
.. code-block:: sh
$ curl -OL https://github.com/carpedm20/fbchat/tarball/master
# optionally, zipball is also available (for Windows users).
# optionally, zipball is also available (for Windows users).
Once you have a copy of the source, you can embed it in your own Python
package, or install it into your site-packages easily::
package, or install it into your site-packages easily:
.. code-block:: sh
$ python setup.py install

View File

@@ -1,4 +1,3 @@
.. highlight:: sh
.. _testing:
Testing
@@ -14,7 +13,9 @@ To use the tests, copy ``tests/data.json`` to ``tests/my_data.json`` or type the
Please remember to test all supported python versions.
If you've made any changes to the 2FA functionality, test it with a 2FA enabled account.
If you only want to execute specific tests, pass the function names in the command line (not including the ``test_`` prefix). Example::
If you only want to execute specific tests, pass the function names in the command line (not including the ``test_`` prefix). Example:
.. code-block:: sh
$ python tests.py sendMessage sessions sendEmoji

View File

@@ -99,11 +99,11 @@ class Message(object):
Returns a `Message` object, with the formatted string and relevant mentions.
>>> Message.formatMentions("Hey {!r}! My name is {}", ("1234", "Peter"), ("4321", "Michael"))
<Message (None): "Hey 'Peter'! My name is Michael", mentions=[<Mention 1234: offset=4 length=7>, <Mention 4321: offset=24 length=7>] emoji_size=None attachments=[]>
>>> Message.formatMentions("Hey {!r}! My name is {}", ("1234", "Peter"), ("4321", "Michael"))
<Message (None): "Hey 'Peter'! My name is Michael", mentions=[<Mention 1234: offset=4 length=7>, <Mention 4321: offset=24 length=7>] emoji_size=None attachments=[]>
>>> Message.formatMentions("Hey {p}! My name is {}", ("1234", "Michael"), p=("4321", "Peter"))
<Message (None): 'Hey Peter! My name is Michael', mentions=[<Mention 4321: offset=4 length=5>, <Mention 1234: offset=22 length=7>] emoji_size=None attachments=[]>
>>> Message.formatMentions("Hey {p}! My name is {}", ("1234", "Michael"), p=("4321", "Peter"))
<Message (None): 'Hey Peter! My name is Michael', mentions=[<Mention 4321: offset=4 length=5>, <Mention 1234: offset=22 length=7>] emoji_size=None attachments=[]>
"""
result = ""
mentions = list()