Finish Tcl/Tk documentation

pull/337/merge
Thibaut Courouble 9 years ago
parent 63c77322d3
commit 23ebf25bcb

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 96 KiB

@ -1,5 +1,8 @@
[
[
"2016-01-31",
"New documentation: <a href=\"/tcl_tk/\">Tcl/Tk</a>"
], [
"2016-01-24",
"&ldquo;Multi-version support&rdquo; has landed!\nClick <a href=\"#\" data-pick-docs>Select documentation</a> to pick which versions to use. More versions will be added in the coming weeks.\nIf you notice any bugs, please report them on <a href=\"https://github.com/Thibaut/devdocs/issues\" target=\"_blank\">GitHub</a>."
], [

@ -384,6 +384,11 @@ credits = [
'2004-2016 Fabien Potencier',
'MIT',
'http://symfony.com/doc/current/contributing/code/license.html'
], [
'Tcl/Tk',
'The Regents of the University of California, Sun Microsystems, Inc., Scriptics Corporation, and other parties',
'Tcl/Tk',
'http://tcl.tk/software/tcltk/license.html'
], [
'Underscore.js',
'2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors',

@ -4,7 +4,7 @@
width: 1rem;
height: 1rem;
background-image: image-url('icons.png');
background-size: 10rem 10rem;
background-size: 10rem 11rem;
}
@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
@ -122,3 +122,4 @@
._icon-flow:before { background-position: -7rem -9rem; }
._icon-relay:before { background-position: -8rem -9rem; }
._icon-phoenix:before { background-position: -9rem -9rem; }
._icon-tcl_tk:before { background-position: 0 -10rem; }

@ -1,19 +1,5 @@
._tcl_tk {
/* make content listing more compact */
.description {
margin: 0;
> dd {
margin: 0;
}
}
dl {
margin: 0;
}
.copy {
/* per page copyright */
white-space: pre;
font-size: 80%;
border-top: 1px solid #6A6A6A;
margin-top: 2em;
}
@extend %simple;
dl { margin: .5em 0; }
}

@ -2,47 +2,37 @@ module Docs
class TclTk
class CleanHtmlFilter < Filter
def call
# Page Title
css('h2').remove
# Navigation
css('h3:first-child').remove
# restore breaks in copyright
txt = at_css('div.copy').content
at_css('div.copy').content = txt.gsub! /.Copyright/, "\n\\0"
css('h2').remove # Page Title
css('h3:first-child').remove # Navigation
css('div.copy').each do |node|
node['class'] = '_attribution'
node.inner_html = %(<p class="_attribution-p">#{node.inner_html.gsub(' Copyright', '<br>\0')}</p>)
end
file = result[:path].split('/')[-1]
re = Regexp.new('^' + Regexp.escape(file) + '(#.*)$')
css('a[name]').each do |node|
if node['href'] then
# useless name
node.remove_attribute 'name'
# make fragments relativ
if node['href'].match re then
node['href'] = node['href'].sub re, '\\1'
end
else
# move name to id
node.parent['id'] = node['name']
node.parent.content = node.content
end
node.before(node.children).remove unless node['href']
end
# remove keywords headline
css('h3').each do |node|
if node.content == 'KEYWORDS' then
node.remove
end
end
# remove keywords links
css('a').each do |node|
attr = node.attribute('href')
if attr && attr.value.match(/\/Keywords\//) then
# the ','
if node.next_sibling then
node.next_sibling.remove
if node.content == 'KEYWORDS'
node['id'] = 'tmp__'
css('#tmp__ ~ a[href*="Keywords"]').each do |link|
link.next.remove if link.next.content == ', '
link.remove
end
node.remove
next
end
node.name = 'h2'
node.content = node.content.capitalize
end
css('h4').each do |node|
node.name = 'h3'
node.content = node.content.capitalize
end
doc

@ -1,56 +1,43 @@
module Docs
class TclTk
class EntriesFilter < Docs::EntriesFilter
#def additional_entries
# type = nil
#end
def split_slug
slug.sub! /\.html?/, ''
return *slug.split('/')
end
TYPE_MAP = {
'UserCmd' => 'Applications',
'TclCmd' => 'Tcl',
'TkCmd' => 'Tk',
'ItclCmd' => 'incr',
'SqliteCmd' => 'tdbc',
'TdbcCmd' => 'tdbc',
'TdbcmysqlCmd' => 'tdbc',
'TdbcodbcCmd' => 'tdbc',
'TdbcpostgresCmd' => 'tdbc',
'TdbcsqliteCmd' => 'tdbc',
'ThreadCmd' => 'Thread',
'UserCmd' => 'App'
'ItclCmd' => '[incr Tcl]',
'SqliteCmd' => 'TDBC',
'TdbcCmd' => 'TDBC',
'TdbcmysqlCmd' => 'TDBC',
'TdbcodbcCmd' => 'TDBC',
'TdbcpostgresCmd' => 'TDBC',
'TdbcsqliteCmd' => 'TDBC',
'ThreadCmd' => 'Thread'
}
def get_type
type, name = split_slug
type = TYPE_MAP[type] || type
if name == 'contents' then
type = nil
def get_name
if slug == 'contents.htm'
TYPE_MAP[slug.split('/').first]
else
slug.split('/').last.remove('.htm')
end
type
end
def get_name
type, name = split_slug
name
def get_type
return nil if name == 'contents'
TYPE_MAP.fetch(slug.split('/').first)
end
def additional_entries
type, name = split_slug
if type != 'TclCmd' || name != 'library' then
return []
end
# special rule for library page which contains multiple commands at once
entries = []
css('a > b').each do |node|
text = node.content.strip
id = node.parent['href'].sub /^.*#(.*)$/, '\\1'
entries << [text, id, TYPE_MAP[type]]
end
return entries
css('> dl.command > dt > a[name]:not([href])', '> dl.commands > dt > a[name]:not([href])').each_with_object [] do |node, entries|
name = node.at_xpath("./b[not(text()='#{self.name}')]").try(:content)
next unless name
name.strip!
name.remove! %r{\A:+}
name.prepend "#{self.name}: " unless name =~ /#{self.name}[:\s]/ || name =~ /#{self.name.gsub('_', '::')}[:\s]/
next if entries.any? { |entry| entry[0] == name }
entries << [name, node['name']]
end
end
end
end

@ -2,41 +2,28 @@ module Docs
class TclTk < UrlScraper
self.name = 'Tcl/Tk'
self.type = 'tcl_tk'
self.slug = 'tcl'
self.version = '8.6'
# test URL:
self.base_url = 'http://localhost/tcl/'
# real URL:
#self.base_url = 'http://www.tcl.tk/man/tcl/'
self.slug = 'tcl_tk'
self.release = '8.6'
self.base_url = 'https://www.tcl.tk/man/tcl/'
self.root_path = 'contents.htm'
html_filters.push 'tcl_tk/clean_html', 'tcl_tk/entries'
options[:skip_links] = false
html_filters.push 'tcl_tk/entries', 'tcl_tk/clean_html', 'title'
options[:root_title] = 'Tcl/Tk Documentation'
options[:trailing_slash] = false
options[:skip] = ['siteinfo.htm']
options[:skip] = %w(siteinfo.htm)
options[:skip_patterns] = [
# ignore keyword list pages
/^Keywords\//,
/\AKeywords\//,
# ignore C-API, only required for extension developers
/^TclLib\//,
/^TkLib\//,
/^ItclLib\//,
/^TdbcLib\//
/\ATclLib\//,
/\ATkLib\//,
/\AItclLib\//,
/\ATdbcLib\//
]
# TODO can't figure out howto convert .htm => .html in filenames
# to save as "xyz.html" instead of "xyz.htm.html"
#options[:fix_urls] = ->(url) do
# url.sub! /\.htm($|#)/, '.html\\1'
# url
#end
# Each Page contains a specific list of copyrights, only add the
# overall license link
options[:attribution] = <<-HTML
Licensed under <a href="http://tcl.tk/software/tcltk/license.html">Tcl/Tk Terms</a>
Licensed under <a href="http://tcl.tk/software/tcltk/license.html">Tcl/Tk terms</a>
HTML
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 444 B

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 992 B

After

Width:  |  Height:  |  Size: 853 B

Loading…
Cancel
Save