Skip to content

Commit

Permalink
Add Disqus and cleanup (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
OttoWinter committed Oct 12, 2018
1 parent 604d7bf commit 150dea5
Show file tree
Hide file tree
Showing 138 changed files with 451 additions and 98 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ _doxyxml
_build

.python-version
__pycache__/
*.py[cod]
*$py.class
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ doxyg: cleandoxyg _doxyxml
cleandoxyg:
rm -rf _doxyxml

_doxyxml: $(ESPHOMELIB_PATH)
_doxyxml:
ESPHOMELIB_PATH=$(ESPHOMELIB_PATH) doxygen Doxygen

$(ESPHOMELIB_PATH):
Expand Down
13 changes: 13 additions & 0 deletions _static/disqus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(function() {
var d = document, s = d.createElement('script');
s.src = 'https://esphomelib.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();

var disqus_config = function () {
let disqusThread = document.getElementById("disqus_thread");
if (disqusThread === null)
return;
this.page.identifier = disqusThread.getAttribute('data-disqus-identifier');
};
7 changes: 3 additions & 4 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@
from sphinx import addnodes
from sphinx.util.docfields import Field, GroupedField
import re
import sys

on_rtd = os.environ.get('READTHEDOCS', None) == 'True'

if on_rtd:
subprocess.call('doxygen', shell=True)

sys.path.append(os.path.abspath('.'))

# -- General configuration ------------------------------------------------

Expand All @@ -44,6 +42,7 @@
# ones.
extensions = [
'breathe',
'disqus',
]

breathe_projects = {"esphomelib": "./_doxyxml/"}
Expand Down
50 changes: 50 additions & 0 deletions disqus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Based on https://github.com/rmk135/sphinxcontrib-disqus
from docutils import nodes
from docutils.parsers.rst import Directive


class DisqusNode(nodes.General, nodes.Element):
def __init__(self, disqus_identifier):
super(DisqusNode, self).__init__()
self.disqus_identifier = disqus_identifier


def disqus_visit(self, node):
html_attrs = {
'ids': ['disqus_thread'],
'data-disqus-identifier': node.disqus_identifier,
}
self.body.append(self.starttag(node, 'div', '', **html_attrs))


def disqus_depart(self, _):
self.body.append('</div>')


class DisqusDirective(Directive):
option_spec = dict(identifier=str)

def get_identifier(self):
if 'identifier' in self.options:
return self.options['identifier']

env = self.state.document.settings.env
return env.docname.replace('/', '-')

def run(self):
disqus_identifier = self.get_identifier()
return [DisqusNode(disqus_identifier)]


def event_html_page_context(app, pagename, templatename, context, doctree):
if not doctree or 'script_files' not in context:
return
if any(hasattr(n, 'disqus_identifier') for n in doctree.traverse()):
context['script_files'] = context['script_files'][:] + ['_static/disqus.js']


def setup(app):
app.add_directive('disqus', DisqusDirective)
app.add_node(DisqusNode, html=(disqus_visit, disqus_depart))
app.connect('html-page-context', event_html_page_context)
return {'version': '1.0'}
8 changes: 5 additions & 3 deletions esphomeyaml/components/ads1115.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To use this hub, first setup the :ref:`I²C Bus <i2c>` and connect the sensor to
- address: 0x48
Configuration variables:
~~~~~~~~~~~~~~~~~~~~~~~~
------------------------

- **address** (**Required**, int): The i²c address of the sensor.
See :ref:`I²C Addresses <ads1115_i2c_addresses>` for more information.
Expand All @@ -30,7 +30,7 @@ Configuration variables:
.. _ads1115_i2c_addresses:

I²C Addresses
~~~~~~~~~~~~~
-------------

In order to allow multiple sensors to be connected to the same i²c bus,
the creators of this sensor hardware have included some options to
Expand All @@ -42,9 +42,11 @@ change the i²c address.
- If the address pin is tied to SCL, the address is ``0x4B``.

See Also
^^^^^^^^
--------

- :doc:`sensor/ads1115`
- `i2cdevlib <https://github.com/jrowberg/i2cdevlib>`__ by `Jeff Rowberg <https://github.com/jrowberg>`__
- :doc:`API Reference </api/sensor/ads1115>`
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/ads1115.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/binary_sensor/esp32_ble_tracker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ See Also
- :doc:`API Reference </api/misc/esp32_ble_tracker>`
- `ESP32 BLE for Arduino <https://github.com/nkolban/ESP32_BLE_Arduino>`__ by `Neil Kolban <https://github.com/nkolban>`__.
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/binary_sensor/esp32_ble_tracker.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/binary_sensor/esp32_touch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,5 @@ See Also
- :doc:`API Reference </api/binary_sensor/esp32_touch>`
- `esp-idf Touch Sensor API <https://esp-idf.readthedocs.io/en/latest/api-reference/peripherals/touch_pad.html>`__
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/binary_sensor/esp32_touch.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/binary_sensor/gpio.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,5 @@ See Also
- :ref:`config-pin_schema`
- :doc:`API Reference </api/binary_sensor/gpio>`
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/binary_sensor/gpio.rst>`__

.. disqus::
17 changes: 7 additions & 10 deletions esphomeyaml/components/binary_sensor/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ You can access the current state of the binary sensor in :ref:`lambdas <config-l
.. _binary_sensor-on_press:

``on_press``
""""""""""""
************

This automation will be triggered when the button is first pressed down, or in other words on the leading
edge of the signal.
Expand All @@ -118,7 +118,7 @@ Configuration variables: See :ref:`Automation <automation>`.
.. _binary_sensor-on_release:

``on_release``
""""""""""""""
**************

This automation will be triggered when a button press ends, or in other words on the falling
edge of the signal.
Expand All @@ -138,7 +138,7 @@ Configuration variables: See :ref:`Automation <automation>`.
.. _binary_sensor-on_click:

``on_click``
""""""""""""
************

This automation will be triggered when a button is pressed down for a time period of length
``min_length`` to ``max_length``. Any click longer or shorter than this will not trigger the automation.
Expand All @@ -165,12 +165,7 @@ Configuration variables:
.. _binary_sensor-on_double_click:

``on_double_click``
"""""""""""""""""""

.. warning::

This trigger is not final and could be replaced by a ``on_multi_click`` option which would
allow triggering for any number of clicks.
*******************

This automation will be triggered when a button is pressed down twice, with the first click lasting between
``min_length`` and ``max_length``. When a second leading edge then happens within ``min_length`` and
Expand All @@ -195,7 +190,7 @@ Configuration variables:
- See :ref:`Automation <automation>`.

lambda calls
""""""""""""
************

From :ref:`lambdas <config-lambda>`, you can call several methods on all binary sensors to do some
advanced stuff (see the full :doc:`API Reference </api/binary_sensor/index>` for more info).
Expand Down Expand Up @@ -241,3 +236,5 @@ See Also
pn532
rdm6300
nextion

.. disqus::
1 change: 1 addition & 0 deletions esphomeyaml/components/binary_sensor/nextion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ See Also
- :doc:`API Reference </api/display/nextion>`
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/binary_sensor/nextion.rst>`__

.. disqus::
1 change: 1 addition & 0 deletions esphomeyaml/components/binary_sensor/pn532.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ See Also
- :doc:`API Reference </api/binary_sensor/pn532>`
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/binary_sensor/pn532.rst>`__

.. disqus::
1 change: 1 addition & 0 deletions esphomeyaml/components/binary_sensor/rdm6300.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ See Also
- :doc:`API Reference </api/binary_sensor/rdm6300>`
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/binary_sensor/rdm6300.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/binary_sensor/remote_receiver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ See Also
- `IRRemoteESP8266 <https://github.com/markszabo/IRremoteESP8266/>`__ by `Mark Szabo-Simon <https://github.com/markszabo>`__
- :doc:`API Reference </api/binary_sensor/remote_receiver>`
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/binary_sensor/remote_receiver.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/binary_sensor/status.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ See Also
- :doc:`/esphomeyaml/components/mqtt`
- :doc:`API Reference </api/binary_sensor/status>`
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/binary_sensor/status.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/binary_sensor/template.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ See Also
- :ref:`automation`
- :doc:`API Reference </api/binary_sensor/template>`
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/binary_sensor/template.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/cover/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,5 @@ See Also
:maxdepth: 1

template.rst

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/cover/template.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,5 @@ See Also
- :doc:`/esphomeyaml/cookbook/garage-door`
- :doc:`API Reference </api/cover/template>`
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/cover/template.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/dallas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ See Also
- `Arduino DallasTemperature library <https://github.com/milesburton/Arduino-Temperature-Control-Library>`__ by `Miles Burton <https://github.com/milesburton>`__
- :doc:`API Reference </api/sensor/dallas>`
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/dallas.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/debug.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ See Also
- :doc:`logger`
- :doc:`API Reference </api/misc/debug>`
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/debug.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/deep_sleep.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,5 @@ See Also
- :ref:`automation`
- :doc:`API Reference </api/core/deep-sleep>`
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/deep_sleep.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/display/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,5 @@ See Also
ssd1306_i2c
ssd1306_spi
waveshare_epaper

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/display/lcd_gpio.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,5 @@ See Also
- :doc:`API Reference </api/display/lcd_display>`
- `Arduino LiquidCrystal Library <https://www.arduino.cc/en/Reference/LiquidCrystal>`__
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/display/lcd_gpio.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/display/lcd_pcf8574.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ See Also
- :doc:`API Reference </api/display/lcd_display>`
- `Arduino LiquidCrystal Library <https://www.arduino.cc/en/Reference/LiquidCrystal>`__
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/display/lcd_pcf8574.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/display/max7219.rst
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,5 @@ See Also
- :doc:`API Reference </api/display/max7219>`
- `MAX7219 Library <https://github.com/nickgammon/MAX7219>`__ by `Nick Gammon <https://github.com/nickgammon>`__
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/display/max7219.rst>`__

.. disqus::
7 changes: 7 additions & 0 deletions esphomeyaml/components/display/nextion.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Nextion TFT LCD Display
=======================

.. warning::

This integration is experimental as I don't have the hardware to test it (yet).
If you can verify it works (or if it doesn't), notify me on `discord <https://discord.gg/KhAMKrd>`__.

The ``nextion`` display platform allows you to use Nextion LCD displays (`datasheet <https://nextion.itead.cc/resources/datasheets/>`__,
`iTead <https://www.itead.cc/display/nextion.html>`__)
with esphomelib.
Expand Down Expand Up @@ -83,3 +88,5 @@ See Also
- `Simple Nextion Library <https://github.com/bborncr/nextion>`__ by `Bentley Born <https://github.com/bborncr>`__
- `Official Nextion Library <https://github.com/itead/ITEADLIB_Arduino_Nextion>`__ by `iTead <http://itead.cc/>`__
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/display/nextion.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/display/ssd1306_i2c.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ See Also
- :doc:`API Reference </api/display/ssd1306>`
- `SSD1306 Library <https://github.com/adafruit/Adafruit_SSD1306>`__ by `Adafruit <http://adafruit.com/>`__
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/display/ssd1306_i2c.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/display/ssd1306_spi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,5 @@ See Also
- :doc:`API Reference </api/display/ssd1306>`
- `SSD1306 Library <https://github.com/adafruit/Adafruit_SSD1306>`__ by `Adafruit <http://adafruit.com/>`__
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/display/ssd1306_spi.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/display/waveshare_epaper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,5 @@ See Also
- :doc:`API Reference </api/display/waveshare_epaper>`
- `Arduino Waveshare E-Paper library <https://github.com/soonuse/epd-library-arduino>`__ by `Yehui (@soonuse) <https://github.com/soonuse>`__
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/display/waveshare_epaper.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/esp32_ble_beacon.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,5 @@ See Also
- :doc:`API Reference </api/misc/esp32_ble_beacon>`
- `ESP32 BLE for Arduino <https://github.com/nkolban/ESP32_BLE_Arduino>`__ by `Neil Kolban <https://github.com/nkolban>`__.
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/esp32_ble_beacon.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/esp32_ble_tracker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,5 @@ See Also
- :doc:`API Reference </api/misc/esp32_ble_tracker>`
- `ESP32 BLE for Arduino <https://github.com/nkolban/ESP32_BLE_Arduino>`__ by `Neil Kolban <https://github.com/nkolban>`__.
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/esp32_ble_tracker.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/esp32_touch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ See Also
- :doc:`binary_sensor/esp32_touch`
- :doc:`API Reference </api/binary_sensor/esp32_touch>`
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/esp32_touch.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/esphomeyaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,5 @@ See Also
--------

- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/esphomeyaml.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/fan/binary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ See Also
- :doc:`/esphomeyaml/components/fan/index`
- :doc:`API Reference </api/fan/index>`
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/fan/binary.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/fan/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,5 @@ Full Fan Index

binary.rst
speed.rst

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/fan/speed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ See Also
- :doc:`/esphomeyaml/components/output/pca9685`
- :doc:`API Reference </api/fan/index>`
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/fan/speed.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/i2c.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ See Also

- :doc:`API Reference </api/core/i2c>`
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/i2c.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/light/binary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ See Also
- :doc:`/esphomeyaml/components/power_supply`
- :doc:`API Reference </api/light/index>`
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/light/binary.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/light/cwww.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ See Also
- :doc:`/esphomeyaml/components/output/pca9685`
- :doc:`API Reference </api/light/index>`
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/light/cwww.rst>`__

.. disqus::
2 changes: 2 additions & 0 deletions esphomeyaml/components/light/fastled_clockless.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ See Also
- :doc:`API Reference </api/light/fastled>`
- `Arduino FastLED library <https://github.com/FastLED/FastLED>`__
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/light/fastled_clockless.rst>`__

.. disqus::
Loading

0 comments on commit 150dea5

Please sign in to comment.