On Mon, Feb 9, 2015 at 3:14 PM, RjOllos <rjol...@gmail.com> wrote:
> INSTALL (5) and UPGRADE (6) duplicate what is provided in TracInstall (7)
> and TracUpgrade (8). Would it be sufficient to just put a link to the wiki
> docs in the files? The link could direct to either the documentation in the
> distribution or to the t.e.o wiki.

Linking to the documentation in the distribution sounds good. INSTALL
and UPGRADE files already navigate the files in the default-pages
directory.

  9 **You should also read the trac/wiki/default-pages/TracInstall
 10 documentation file present in the source distribution.**
 11
 12 If you're upgrading an already installed Trac environment, please also
 13 read trac/wiki/default-pages/TracUpgrade.

However, I assume that users read INSTALL and UPGRADE files on the
user's terminal. TracInstall and TracUpgrade file have too long lines
(over 80 columns).


> If there's a good reason to not take that approach, maybe there's another
> way to eliminate the duplication, such as exporting from the wiki to ReST or
> MarkDown? Unfortunately we don't have those features yet.

I tried to convert TracInstall using pypi:trac2rst but an IndexError is raised.
Another idea is using pypi:html2rest library after converting Trac
wiki to html. See attached wiki2rst.py.

$ pip install html2rest
$ PYTHONPATH=. python contrib/wiki2rst.py TracInstall

-- 
Jun Omae <jun6...@gmail.com> (大前 潤)

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to trac-dev+unsubscr...@googlegroups.com.
To post to this group, send email to trac-dev@googlegroups.com.
Visit this group at http://groups.google.com/group/trac-dev.
For more options, visit https://groups.google.com/d/optout.
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os.path
import sys

from cStringIO import StringIO
from html2rest import html2rest
from pkg_resources import resource_listdir, resource_string

from trac.loader import load_components
from trac.test import EnvironmentStub, Mock, MockPerm
from trac.util.text import printout
from trac.web.chrome import web_context
from trac.web.href import Href
from trac.wiki.formatter import format_to_html
from trac.wiki.model import WikiPage


def main():
    names = sorted(name for name in resource_listdir('trac.wiki',
                                                     'default-pages')
                        if not name.startswith('.'))

    env = EnvironmentStub()
    load_components(env)
    with env.db_transaction:
        for name in names:
            wiki = WikiPage(env, name)
            wiki.text = resource_string('trac.wiki', 'default-pages/' +
                                        name).decode('utf-8')
            if wiki.text:
                wiki.save('trac', '')
            else:
                printout('%s: Skipped empty page' % name)

    req = Mock(href=Href('/'), abs_href=Href('http://trac.edgewall.org/'),
               perm=MockPerm())
    for name in sys.argv[1:]:
        name = os.path.basename(name)
        wiki = WikiPage(env, name)
        if not wiki.exists:
            continue
        context = web_context(req, wiki.resource, absurls=True)
        html = '<html><body>%s</body></html>' % \
               format_to_html(env, context, wiki.text).encode('utf-8')
        out = StringIO()
        html2rest(html, writer=out)
        out = out.getvalue().replace(': http://trac.edgewall.org/wiki/',
                                     ': trac/wiki/default-pages/')
        sys.stdout.write(out)


if __name__ == '__main__':
    main()

Reply via email to