Skip to content

Instantly share code, notes, and snippets.

View shimizukawa's full-sized avatar

Takayuki SHIMIZUKAWA shimizukawa

View GitHub Profile
@shimizukawa
shimizukawa / sphinx-i18n-avoid-unusable-warnings.patch
Created November 29, 2012 13:20
sphinx i18n avoid unusable warnings patch.
diff -r 8a5db9f7719d -r 02d86c1ce059 sphinx/environment.py
--- a/sphinx/environment.py Tue Nov 27 20:07:30 2012 +0900
+++ b/sphinx/environment.py Thu Nov 29 15:46:57 2012 +0900
@@ -219,6 +219,14 @@
if not msgstr or msgstr == msg: # as-of-yet untranslated
continue
+ # Avoid "Literal block expected; none found." warnings.
+ # If msgstr ends with '::' then it cause warning message at
+ # parser.parse() processing.
@shimizukawa
shimizukawa / decode_inventory_of_sphinx.py
Created November 30, 2012 00:20
sphinx inventory loading
import urllib
import zlib
inv = urllib.urlopen('http://docs.python.org/2/objects.inv').read()
raw_inv = zlib.decompress('\n'.join(l for l in da.splitlines() if l and l[0]!='#'))
raw_inv.splitlines()[0]
# -> '-v std:option 1 using/cmdline.html#cmdoption$ -'
# it's a first line of raw inventory data
@shimizukawa
shimizukawa / ext_ctags.py
Created November 30, 2012 03:38
ctags file generator for sphinx
# -*- coding: utf-8 -*-
import os
def doctree_resolved(app, doctree, docname):
filename = os.path.join(app.confdir, app.config.ctags_filename)
# load existent ctag
ctags = load_ctag(filename)
@shimizukawa
shimizukawa / README.rst
Created December 1, 2012 07:45
Sphinx extension "Anonimous Domain" extend objects.inv entries.

Anonymous Domain

Anonymous domain hook anonymous link target and store targets into objects.inv.

Problem

objects.inv not have anonymous link targets.

@shimizukawa
shimizukawa / ubuntu
Created December 11, 2012 13:56
sphinx build (46ee365a865d) by python3.1.x
ubuntu:~/sphinx-master$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=11.04
DISTRIB_CODENAME=natty
DISTRIB_DESCRIPTION="Ubuntu 11.04"
ubuntu:~/sphinx-master$ uname -a
Linux ubuntu 2.6.38-13-server #53-Ubuntu SMP Mon Nov 28 19:52:56 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
ubuntu:~/sphinx-master$ python3.1 -V
@shimizukawa
shimizukawa / conf.py
Last active April 9, 2016 14:44
Adding custom directives and roles for Sphinx syntax it also provide index information / Sphinxの独自directive, roleを定義してアウトプットを整形したりindex化したり。
# http://sphinx-users.jp/doc11/ext/appapi.html#sphinx.application.Sphinx.add_object_type
# -- add config field --
from sphinx import addnodes
from sphinx.util.docfields import Field, GroupedField
import re
def iniref_parse_format(env, sig, signode):
@shimizukawa
shimizukawa / autodoc.diff
Last active December 11, 2015 00:28
sphinx autodoc patch for descriptor-class documentation. reported behavior is here: https://gist.github.com/4503973
diff -r cfbdd84c1d6f sphinx/ext/autodoc.py
--- a/sphinx/ext/autodoc.py Thu Jan 10 21:58:18 2013 -0600
+++ b/sphinx/ext/autodoc.py Sat Jan 12 16:07:02 2013 +0900
@@ -1190,6 +1190,7 @@
def can_document_member(cls, member, membername, isattr, parent):
isdatadesc = isdescriptor(member) and not \
isinstance(member, cls.method_types) and not \
+ type(member).__name__ == "type" and not \
type(member).__name__ == "method_descriptor"
return isdatadesc or (not isinstance(parent, ModuleDocumenter)
@shimizukawa
shimizukawa / conf.py
Last active December 11, 2015 04:28
sphinx: doc reference by using substitution and custome 'doc' inline directive. inspired by https://bitbucket.org/birkenfeld/sphinx/issue/1077
############################################
# inline doc directive for substitution
# rst: .. |sub| doc:: docname
# html: <a href="docname.html">sub</a>
from sphinx.util.compat import Directive
from sphinx.roles import XRefRole
class DocDirective(Directive):
required_arguments = 1
@shimizukawa
shimizukawa / PIL_build.rst
Last active December 11, 2015 17:28
PIL (Pillow) build procedure

PIL(Pillow) build on Windows (32bit)

If you want to build PIL on Windows, you need to prepare few external libraries. Although some libraries did not provide static library for windows 32/64 bits then you need to build these libraries by your hand too. Also, PIL will load by python at last then you are recommended to use same compiler with python to build libraries.

Target PIL and versions

PIL:1.1.7 for Python 2.4 (or Pillow-1.7.8)
@shimizukawa
shimizukawa / PIL_build.rst
Last active June 26, 2016 14:32 — forked from adrianer/PIL_build.rst
PIL(Pillow) build on Windows (32bit & 64bit)

PIL(Pillow) build on Windows (32bit & 64bit)

If you want to build PIL on Windows, you need to prepare few external libraries. Although some libraries did not provide static library for windows 32/64 bits then you need to build these libraries by your hand too. Also, PIL will load by python at last then you are recommended to use same compiler with python to build libraries.

Target PIL and versions

Pillow:1.7.8 for Python 2.7: src