You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by dj...@apache.org on 2013/11/09 16:25:20 UTC

git commit: updated refs/heads/dash-docset to d56471a

Updated Branches:
  refs/heads/dash-docset [created] d56471a1c


docs: enable building a Dash docset


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d56471a1
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d56471a1
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d56471a1

Branch: refs/heads/dash-docset
Commit: d56471a1cbecf50512d65d58181201873330db16
Parents: b9fbec6
Author: Dirkjan Ochtman <di...@ochtman.nl>
Authored: Sat Nov 9 16:23:38 2013 +0100
Committer: Dirkjan Ochtman <di...@ochtman.nl>
Committed: Sat Nov 9 16:23:38 2013 +0100

----------------------------------------------------------------------
 share/doc/build/Makefile.am    |   1 +
 share/doc/ext/dashdocset.py    | 116 ++++++++++++++++++++++++++++++++++++
 share/doc/images/icon-32px.png | Bin 0 -> 819 bytes
 share/doc/src/conf.py          |   2 +-
 4 files changed, 118 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/d56471a1/share/doc/build/Makefile.am
----------------------------------------------------------------------
diff --git a/share/doc/build/Makefile.am b/share/doc/build/Makefile.am
index a6a5e76..a521db3 100644
--- a/share/doc/build/Makefile.am
+++ b/share/doc/build/Makefile.am
@@ -453,6 +453,7 @@ src_files_html = \
 
 sphinx_extensions = \
     ../ext/configdomain.py \
+    ../ext/dashdocset.py \
     ../ext/github.py \
     ../ext/httpdomain.py \
     ../ext/http-api-descr.json

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d56471a1/share/doc/ext/dashdocset.py
----------------------------------------------------------------------
diff --git a/share/doc/ext/dashdocset.py b/share/doc/ext/dashdocset.py
new file mode 100644
index 0000000..a17518b
--- /dev/null
+++ b/share/doc/ext/dashdocset.py
@@ -0,0 +1,116 @@
+## Licensed under the Apache License, Version 2.0 (the "License"); you may not
+## use this file except in compliance with the License. You may obtain a copy of
+## the License at
+##
+##   http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+## License for the specific language governing permissions and limitations under
+## the License.
+
+# Based on Ruby script by Stephen Benner
+# https://github.com/SteveBenner/couchdb-dash-docset/
+
+from lxml import html
+from sphinx.util.console import bold
+import urllib2, os, sqlite3, shutil, plistlib, imp, tarfile
+
+FILE_PATH = os.path.abspath(__file__)
+DOC_DIR = os.path.dirname(os.path.dirname(FILE_PATH))
+BUILD_DIR = os.path.join(DOC_DIR, 'build', 'html')
+ICON_SRC = os.path.join(DOC_DIR, 'images', 'icon-32px.png')
+
+DS_DIR = os.path.join(BUILD_DIR, 'CouchDB.docset')
+DOCS = os.path.join(DS_DIR, 'Contents', 'Resources', 'Documents')
+PLIST_PATH = os.path.join(DS_DIR, 'Contents', 'info.plist')
+DB_PATH = os.path.join(DS_DIR, 'Contents', 'Resources', 'docSet.dsidx')
+
+FEED_PATH = os.path.join(BUILD_DIR, 'CouchDB.xml')
+DIST_PATH = os.path.join(BUILD_DIR, 'CouchDB.tgz')
+
+PLIST = {
+    'CFBundleIdentifier': 'CouchDB',
+    'DocSetPlatformFamily': 'CouchDB',
+    'isDashDocset': True,
+    'DocSetPublisherName': 'Apache CouchDB Project',
+    'dashIndexFilePath': 'index.html',
+    'isJavaScriptEnabled': True,
+}
+
+def ignore(dir, contents):
+    if '_sources' in dir:
+        return contents
+    elif 'docset' in dir:
+        return contents
+    else:
+        return []
+
+def build(app, exception):
+    
+    if exception is not None:
+        return
+    
+    if 'HTML' not in app.builder.__class__.__name__:
+        return
+    
+    app.info(bold('building docset...'), True)
+    entries = []
+    title = lambda s: s.split(' ', 1)[1]
+    contents = html.parse(open(os.path.join(BUILD_DIR, 'contents.html')))
+    for a in contents.findall('.//li[@class="toctree-l1"]/a'):
+        entries.append(('Guide', title(a.text), a.attrib['href']))
+    
+    for a in contents.findall('.//li[@class="toctree-l1"][10]/ul/li/a'):
+        if title(a.text) == 'API Basics': continue
+        entries.append(('Category', title(a.text), a.attrib['href']))
+    
+    for a in contents.findall('.//li[@class="toctree-l1"][11]/ul/li/a'):
+        entries.append(('Struct', title(a.text), a.attrib['href']))
+    
+    for a in contents.findall('.//li[@class="toctree-l1"][3]/ul/li/ul/li/a'):
+        if a.text.startswith('3.1'): continue
+        entries.append(('Option', title(a.text), a.attrib['href']))
+    
+    for a in contents.findall('.//li[@class="toctree-l1"][10]/ul/li/ul/li/a'):
+        if a.text.startswith('10.1'): continue
+        text = title(''.join(i for i in a.itertext()))
+        entries.append(('Method', text, a.attrib['href']))
+    
+    os.makedirs(os.path.dirname(DOCS))
+    shutil.copyfile(ICON_SRC, os.path.join(DS_DIR, 'icon.png'))
+    shutil.copytree(BUILD_DIR, DOCS, ignore=ignore)
+    PLIST['CFBundleName'] = 'CouchDB ' + app.config.version
+    plistlib.writePlist(PLIST, PLIST_PATH)
+    
+    db = sqlite3.connect(DB_PATH)
+    cur = db.cursor()
+    cur.execute('CREATE TABLE searchIndex ('
+                    'id INTEGER PRIMARY KEY, '
+                    'name TEXT, '
+                    'type TEXT, '
+                     'path TEXT'
+                ');')
+    
+    cur.execute('CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path);')
+    for e in entries:
+        cur.execute('INSERT INTO searchIndex (type, name, path) VALUES (?, ?, ?)', e)
+    
+    db.commit()
+    db.close()
+    
+    with tarfile.open(DIST_PATH, 'w:gz') as f:
+        f.add(DS_DIR)
+
+    shutil.rmtree(DS_DIR)
+    with open(FEED_PATH, 'w') as f:
+        print >> f, '<entry>'
+        print >> f, '<version>%s</version>' % app.config.version
+        print >> f, '<url>http://docs.couchdb.org/latest/en/CouchDB.tgz</url>'
+        print >> f, '</entry>'
+   
+    app.info(' done')
+
+def setup(app):
+    app.connect('build-finished', build)

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d56471a1/share/doc/images/icon-32px.png
----------------------------------------------------------------------
diff --git a/share/doc/images/icon-32px.png b/share/doc/images/icon-32px.png
new file mode 100644
index 0000000..aaf8f94
Binary files /dev/null and b/share/doc/images/icon-32px.png differ

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d56471a1/share/doc/src/conf.py
----------------------------------------------------------------------
diff --git a/share/doc/src/conf.py b/share/doc/src/conf.py
index 3d2536e..73da03d 100644
--- a/share/doc/src/conf.py
+++ b/share/doc/src/conf.py
@@ -18,7 +18,7 @@ import sys
 sys.path.insert(0, os.path.abspath('../ext'))
 
 extensions = ["sphinx.ext.todo", "sphinx.ext.extlinks", 'github',
-              'httpdomain', 'configdomain']
+              'httpdomain', 'configdomain', 'dashdocset']
 
 _info = {}
 _regex = re.compile('m4_define\(\[(.+)\],\s+\[(.+)\]\)')


Re: git commit: updated refs/heads/dash-docset to d56471a

Posted by Simon Metson <si...@cloudant.com>.
Great :) 


On Sunday, 10 November 2013 at 09:37, Dirkjan Ochtman wrote:

> On Sat, Nov 9, 2013 at 9:37 PM, Alexander Shorin <kxepal@gmail.com (mailto:kxepal@gmail.com)> wrote:
> > That was Stephen Benner and he's mentioned in comments (;
> 
> 
> 
> Right, though I should definitely have mentioned him in my email as well.
> 
> Stephen did two revisions of a Ruby script for this (linked to from my
> Python version), then graciously relicensed that version from GPL to
> MIT so I could safely do a derivative under the ASF license; I've done
> some back and forth with him over the past weeks, so much thanks is
> due to him!
> 
> Cheers,
> 
> Dirkjan 



Re: git commit: updated refs/heads/dash-docset to d56471a

Posted by Dirkjan Ochtman <di...@ochtman.nl>.
On Sat, Nov 9, 2013 at 9:37 PM, Alexander Shorin <kx...@gmail.com> wrote:
> That was Stephen Benner and he's mentioned in comments (;

Right, though I should definitely have mentioned him in my email as well.

Stephen did two revisions of a Ruby script for this (linked to from my
Python version), then graciously relicensed that version from GPL to
MIT so I could safely do a derivative under the ASF license; I've done
some back and forth with him over the past weeks, so much thanks is
due to him!

Cheers,

Dirkjan

Re: git commit: updated refs/heads/dash-docset to d56471a

Posted by Alexander Shorin <kx...@gmail.com>.
On Sun, Nov 10, 2013 at 12:29 AM, Simon Metson <si...@cloudant.com> wrote:
> Iirc there was someone on the CouchDB irc channel that had done this already. Will dig through my logs when back at a laptop.

That was Stephen Benner and he's mentioned in comments (;

--
,,,^..^,,,

Re: git commit: updated refs/heads/dash-docset to d56471a

Posted by Simon Metson <si...@cloudant.com>.
Iirc there was someone on the CouchDB irc channel that had done this already. Will dig through my logs when back at a laptop.  


On Saturday, 9 November 2013 at 18:59, Andy Wenk wrote:

> I never heard of Dash ... unfortunately ;-). After a first glimps, this app
> is really cool. +1 for generating a docset for CouchDB
> 
> 
> On 9 November 2013 16:30, Dirkjan Ochtman <dj...@apache.org> wrote:
> 
> > On Sat, Nov 9, 2013 at 4:25 PM, <dj...@apache.org> wrote:
> > > Updated Branches:
> > > refs/heads/dash-docset [created] d56471a1c
> > > 
> > > docs: enable building a Dash docset
> > 
> > http://git-wip-us.apache.org/repos/asf/couchdb/commit/d56471a1
> > 
> > Dash (http://kapeli.com/dash) is an app on the Mac App Store that
> > makes it easy to download offline sets of documentation. It has a
> > pluggable model where you can create your own docsets by bundling up
> > some HTML and a little SQLite database.
> > 
> > I think it would be cool if we could host a somewhat-automatically
> > updating Dash docset for CouchDB on RTD, so I've integrated it in our
> > Sphinx setup by wrapping things in a Sphinx extension. However, this
> > doesn't completely work with our build system yet.
> > 
> > Anyone else interested in this?
> > 
> > Cheers,
> > 
> > Dirkjan
> 
> 
> 
> -- 
> Andy Wenk
> Hamburg - Germany
> RockIt!
> 
> http://www.couchdb-buch.de
> http://www.pg-praxisbuch.de
> 
> GPG fingerprint: C044 8322 9E12 1483 4FEC 9452 B65D 6BE3 9ED3 9588 


Re: git commit: updated refs/heads/dash-docset to d56471a

Posted by Andy Wenk <an...@nms.de>.
I never heard of Dash ... unfortunately ;-). After a first glimps, this app
is really cool. +1 for generating a docset for CouchDB


On 9 November 2013 16:30, Dirkjan Ochtman <dj...@apache.org> wrote:

> On Sat, Nov 9, 2013 at 4:25 PM,  <dj...@apache.org> wrote:
> > Updated Branches:
> >   refs/heads/dash-docset [created] d56471a1c
> >
> > docs: enable building a Dash docset
>
> http://git-wip-us.apache.org/repos/asf/couchdb/commit/d56471a1
>
> Dash (http://kapeli.com/dash) is an app on the Mac App Store that
> makes it easy to download offline sets of documentation. It has a
> pluggable model where you can create your own docsets by bundling up
> some HTML and a little SQLite database.
>
> I think it would be cool if we could host a somewhat-automatically
> updating Dash docset for CouchDB on RTD, so I've integrated it in our
> Sphinx setup by wrapping things in a Sphinx extension. However, this
> doesn't completely work with our build system yet.
>
> Anyone else interested in this?
>
> Cheers,
>
> Dirkjan
>



-- 
Andy Wenk
Hamburg - Germany
RockIt!

http://www.couchdb-buch.de
http://www.pg-praxisbuch.de

GPG fingerprint: C044 8322 9E12 1483 4FEC 9452 B65D 6BE3 9ED3 9588

Re: git commit: updated refs/heads/dash-docset to d56471a

Posted by Jan Lehnardt <ja...@apache.org>.
On 19 Nov 2013, at 19:54 , Dirkjan Ochtman <di...@ochtman.nl> wrote:

> On Tue, Nov 19, 2013 at 1:58 AM, Jan Lehnardt <ja...@apache.org> wrote:
>> I’m happy to set up a jenkins build that publishes new versions of
>> the Dash doc set.
> 
> Are you saying you'd prefer to not put this in the build system by
> default, but let it be handled by some Jenkins job?

Nah, I just volunteered for setting something up in Jenkins should
the need arise :)

Jan
-- 


Re: git commit: updated refs/heads/dash-docset to d56471a

Posted by Dirkjan Ochtman <di...@ochtman.nl>.
On Tue, Nov 19, 2013 at 1:58 AM, Jan Lehnardt <ja...@apache.org> wrote:
> I’m happy to set up a jenkins build that publishes new versions of
> the Dash doc set.

Are you saying you'd prefer to not put this in the build system by
default, but let it be handled by some Jenkins job?

Cheers,

Dirkjan

Re: git commit: updated refs/heads/dash-docset to d56471a

Posted by Jan Lehnardt <ja...@apache.org>.
On 09 Nov 2013, at 07:30 , Dirkjan Ochtman <dj...@apache.org> wrote:

> On Sat, Nov 9, 2013 at 4:25 PM,  <dj...@apache.org> wrote:
>> Updated Branches:
>>  refs/heads/dash-docset [created] d56471a1c
>> 
>> docs: enable building a Dash docset
> 
> http://git-wip-us.apache.org/repos/asf/couchdb/commit/d56471a1
> 
> Dash (http://kapeli.com/dash) is an app on the Mac App Store that
> makes it easy to download offline sets of documentation. It has a
> pluggable model where you can create your own docsets by bundling up
> some HTML and a little SQLite database.
> 
> I think it would be cool if we could host a somewhat-automatically
> updating Dash docset for CouchDB on RTD, so I've integrated it in our
> Sphinx setup by wrapping things in a Sphinx extension. However, this
> doesn't completely work with our build system yet.
> 
> Anyone else interested in this?

I had a note to look into this. It is great to see things already moving
along :)

I’m happy to set up a jenkins build that publishes new versions of
the Dash doc set.

Best
Jan
-- 


Re: git commit: updated refs/heads/dash-docset to d56471a

Posted by Dirkjan Ochtman <dj...@apache.org>.
On Sat, Nov 9, 2013 at 4:25 PM,  <dj...@apache.org> wrote:
> Updated Branches:
>   refs/heads/dash-docset [created] d56471a1c
>
> docs: enable building a Dash docset

http://git-wip-us.apache.org/repos/asf/couchdb/commit/d56471a1

Dash (http://kapeli.com/dash) is an app on the Mac App Store that
makes it easy to download offline sets of documentation. It has a
pluggable model where you can create your own docsets by bundling up
some HTML and a little SQLite database.

I think it would be cool if we could host a somewhat-automatically
updating Dash docset for CouchDB on RTD, so I've integrated it in our
Sphinx setup by wrapping things in a Sphinx extension. However, this
doesn't completely work with our build system yet.

Anyone else interested in this?

Cheers,

Dirkjan