Commits

Sebastian Wiesner  committed 504136d Merge

Merge heads

  • Participants
  • Parent commits 052594f, 9057db7

Comments (0)

Files changed (9)

 
 hyphenator:
    Björn Müller <diehose@freenet.de> 
+
+youtube:
+   Chris Pickel <sfiera@gmail.com>
   docstrings), mark statuses and collect them in a single list 
 - googlechart: embed charts by using Google Chart_
 - hyphenator: client-side hyphenation of HTML using hyphenator_
+- youtube: embed videos from YouTube_
 
 .. _aafigure: http://docutils.sourceforge.net/sandbox/aafigure/
 
 
 .. _exceltable: http://packages.python.org/sphinxcontrib-exceltable/
 
+.. _YouTube: http://www.youtube.com/
+
 For contributors
 ================
 

File youtube/MANIFEST.in

+include README
+include LICENSE
+include CHANGES.*

File youtube/README

+sphinxcontrib.youtube
+=====================
+
+This module defines a directive, `youtube`.  It takes a single, required
+argument, a YouTube video ID::
+
+    ..  youtube:: oHg5SJYRHA0
+
+The referenced video will be embedded into HTML output.  By default, the
+embedded video will be sized for 720p content.  To control this, the
+parameters "width" and "height" may optionally be provided::
+
+    ..  youtube:: oHg5SJYRHA0
+        :width: 640
+        :height: 480
+
+..  -*- mode: rst; fill-column: 72 -*-

File youtube/setup.cfg

+[egg_info]
+tag_build = dev
+tag_date = true
+
+[aliases]
+release = egg_info -RDb ''

File youtube/setup.py

+# -*- coding: utf-8 -*-
+
+from setuptools import setup, find_packages
+
+long_desc = '''
+This package contains the youtube Sphinx extension.
+
+The extension defines a directive, "youtube", for embedding YouTube
+videos.
+'''
+
+requires = ['Sphinx>=0.6']
+
+setup(
+    name='sphinxcontrib-youtube',
+    version='1.0',
+    url='http://bitbucket.org/birkenfeld/sphinx-contrib',
+    download_url='http://pypi.python.org/pypi/sphinxcontrib-youtube',
+    license='BSD',
+    author='Chris Pickel',
+    author_email='sfiera@gmail.com',
+    description='Sphinx "youtube" extension',
+    long_description=long_desc,
+    zip_safe=False,
+    classifiers=[
+        'Development Status :: 4 - Beta',
+        'Environment :: Console',
+        'Environment :: Web Environment',
+        'Intended Audience :: Developers',
+        'License :: OSI Approved :: BSD License',
+        'Operating System :: OS Independent',
+        'Programming Language :: Python',
+        'Topic :: Documentation',
+        'Topic :: Utilities',
+    ],
+    platforms='any',
+    packages=find_packages(),
+    include_package_data=True,
+    install_requires=requires,
+    namespace_packages=['sphinxcontrib'],
+)

File youtube/sphinxcontrib/__init__.py

+# -*- coding: utf-8 -*-
+"""
+    sphinxcontrib
+    ~~~~~~~~~~~~~
+
+    This package is a namespace package that contains all extensions
+    distributed in the ``sphinx-contrib`` distribution.
+
+    :copyright: Copyright 2007-2009 by the Sphinx team, see AUTHORS.
+    :license: BSD, see LICENSE for details.
+"""
+
+__import__('pkg_resources').declare_namespace(__name__)
+

File youtube/sphinxcontrib/youtube.py

+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from docutils import nodes
+from docutils.parsers.rst import directives
+from sphinx.util.compat import Directive
+
+class youtube(nodes.General, nodes.Element): pass
+
+def visit_youtube_node(self, node):
+    attrs = {
+        "src": "http://www.youtube.com/embed/%s" % node["id"],
+        "width": str(node["width"]),
+        "height": str(node["height"]),
+        "frameborder": "0",
+    }
+    self.body.append(self.starttag(node, "iframe", **attrs))
+    self.body.append("</iframe>")
+
+def depart_youtube_node(self, node):
+    pass
+
+class YouTube(Directive):
+    has_content = True
+    required_arguments = 1
+    optional_arguments = 0
+    final_argument_whitespace = False
+    option_spec = {
+        "width": directives.unchanged,
+        "height": directives.unchanged,
+    }
+
+    def run(self):
+        width = int(self.options.get("width", 560))
+        height = int(self.options.get("height", 345))
+        return [youtube(id=self.arguments[0], width=width, height=height)]
+
+def setup(app):
+    app.add_node(youtube, html=(visit_youtube_node, depart_youtube_node))
+    app.add_directive("youtube", YouTube)

File youtube/tox.ini

+## configuration for tox <http://codespeak.net/tox/>
+
+## tox automates running certain tasks within virtualenvs.  The following
+## tox configuration outlines a basic setup for running unit tests and
+## building sphinx docs in separate virtual environments.  Give it a try!
+
+[tox]
+envlist=python,doc
+
+# test running
+[testenv:python]
+deps=
+    ## if you use nose for test running
+    # nose
+    ## if you use py.test for test running
+    # pytest
+commands=
+    ## run tests with py.test
+    # py.test []
+    ## run tests with nose
+    # nose
+
+[testenv:doc]
+deps=
+    sphinx
+    # add all Sphinx extensions and other dependencies required to build your docs
+commands=
+    ## test links
+    # sphinx-build -W -b linkcheck -d {envtmpdir}/doctrees doc {envtmpdir}/linkcheck
+    ## test html output
+    # sphinx-build -W -b html -d {envtmpdir}/doctrees doc {envtmpdir}/html
+