mirror of https://github.com/freeCodeCamp/devdocs
commit c3ef7a7e99543e56055237faa452b5f7b7b662cc Author: Mathieu PATUREL <australie.p@gmail.com> Date: Thu May 24 22:28:42 2018 +1000 ✨ add prefix to funtions commit b111b3445240d92ee89ba219d638918971f3695e Author: Mathieu PATUREL <australie.p@gmail.com> Date: Thu May 24 22:08:21 2018 +1000 FileScraper to UrlScraper commit d02a11e479788c7d10ffc6f43d8796134c26c212 Author: Mathieu PATUREL <australie.p@gmail.com> Date: Thu May 24 18:53:42 2018 +1000 ✨ remove 'pygame.' in entries commit 1d579e52d788195eefdf4f55877d41722f6bfbd2 Author: Mathieu PATUREL <australie.p@gmail.com> Date: Thu May 24 17:23:34 2018 +1000 🔥 remove useless code commit 60ea8151de073ed8ee9e16abe3e934f1afb934be Author: Mathieu PATUREL <australie.p@gmail.com> Date: Thu May 24 17:20:09 2018 +1000 ✨ added icons commit 73128c33ec5e6d762c6e3068e16994738006ef26 Author: Mathieu PATUREL <australie.p@gmail.com> Date: Thu May 24 14:07:44 2018 +1000 :sprakles: proper attribution commit 69dceb531bf83b0ea34a2f4ffa09104ab76193ec Author: Mathieu PATUREL <australie.p@gmail.com> Date: Wed May 23 00:56:56 2018 +1000 ✨ added syntax highlighting commit 124460dc31afc7a5bbabd55daadea7defd134ff3 Author: Mathieu PATUREL <australie.p@gmail.com> Date: Wed May 23 00:46:53 2018 +1000 ✨ remove wrapping div commit d213d165cb582856080ba63b9ae2c5d38a0a79b6 Author: Mathieu PATUREL <australie.p@gmail.com> Date: Wed May 23 00:39:29 2018 +1000 🐛 fix index commit f184456e165e4d1104fe4846be311036d4e85b9f Author: Mathieu PATUREL <australie.p@gmail.com> Date: Wed May 23 00:13:57 2018 +1000 🔥 remove useless code commit 9cf27eb1be7038c858383c60255cc41ce1f0fd1b Author: Mathieu PATUREL <australie.p@gmail.com> Date: Wed May 23 00:12:27 2018 +1000 ✨ use signature as title! it handles 1+ signatures commit ab255f9c791bf53fb144cfe94bb6fa8675fa5ee7 Author: Mathieu PATUREL <australie.p@gmail.com> Date: Tue May 22 23:53:51 2018 +1000 ✨ better semantic & entries commit e1a5bdac68cc84dc243b53061a6e73744694705a Author: Mathieu PATUREL <australie.p@gmail.com> Date: Tue May 22 23:50:09 2018 +1000 ✨ better semantic & entries commit 1913ad6cad25c19c148d4e8ec2ab71dcd2cb9b92 Author: Mathieu PATUREL <australie.p@gmail.com> Date: Tue May 22 23:38:10 2018 +1000 🐛 proper id/name for functions in sidebar commit c1f2b9570ffa4fe55ec975c15093bbec8fbdac47 Author: Mathieu PATUREL <australie.p@gmail.com> Date: Tue May 22 23:30:06 2018 +1000 ✨ move signature to summary commit 2a83023ecf08648dc6898d62e0b9a2a22e9dd583 Author: Mathieu PATUREL <australie.p@gmail.com> Date: Tue May 22 23:26:31 2018 +1000 ✨ move signature to summary commit 00a26a551f433b1aea1496385541e29ca343d5a3 Author: Mathieu PATUREL <australie.p@gmail.com> Date: Tue May 22 23:08:39 2018 +1000 ✨ much better use of h1/h2/h3 commit a134629fd89d4bc700a01242848713f4c3d23427 Author: Mathieu PATUREL <australie.p@gmail.com> Date: Tue May 22 22:48:31 2018 +1000 now cleaning the html commit 51cc6f758af9272131c3e795eed08b6b44f2e182 Author: Mathieu PATUREL <australie.p@gmail.com> Date: Tue May 22 18:21:23 2018 +1000 🎨 remove headerlinks from clean_filter commit c44937f55dbd503647e474f374529cbbf82c257e Author: Mathieu PATUREL <australie.p@gmail.com> Date: Tue May 22 18:16:45 2018 +1000 🐛 fix initial page to scrap commit c313b5b4e5e7611c6859678c23a32d0a30fb6bb4 Author: Mathieu PATUREL <australie.p@gmail.com> Date: Tue May 22 18:15:44 2018 +1000 🐛 load only ref/* commit 5a9782f2617c184c9874a8e8afc6f306cd96af05 Author: Mathieu PATUREL <australie.p@gmail.com> Date: Tue May 22 18:00:52 2018 +1000 🐛 remove unicode in entries commit 958ec50d28d6d94a34e7045e9048b90f0bb10cba Author: Mathieu PATUREL <australie.p@gmail.com> Date: Tue May 22 17:57:47 2018 +1000 ✨ entries basically working commit a5247ce4b2efc3613814ee79010c006a1e1a166b Author: Mathieu PATUREL <australie.p@gmail.com> Date: Tue May 22 17:06:38 2018 +1000 🚧 going with an exceptionpull/810/head
parent
dd6f34a89d
commit
f1045e8fb5
@ -0,0 +1,104 @@
|
||||
module Docs
|
||||
class Pygame
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
|
||||
@doc = at_css '.body'
|
||||
|
||||
if root_page?
|
||||
# remove unneeded stuff
|
||||
at_css('.modindex-jumpbox').remove
|
||||
css('[role="navigation"],.pcap, .cap, .footer').each do |node|
|
||||
node.remove
|
||||
end
|
||||
# table -> list
|
||||
list = at_css('table')
|
||||
list.replace(list.children)
|
||||
list.name = 'ul'
|
||||
css('tr').each do |row|
|
||||
row.name = 'li'
|
||||
row['class'] = ''
|
||||
end
|
||||
return doc
|
||||
end
|
||||
|
||||
# remove unwanted stuff
|
||||
# .headerlink => ¶ after links
|
||||
# .toc => table of content
|
||||
# .tooltip-content => tooltips after links to functions
|
||||
if toremove = css('table.toc.docutils, .headerlink, .tooltip-content')
|
||||
toremove.each do |node|
|
||||
node.remove
|
||||
end
|
||||
end
|
||||
|
||||
# Remove wrapper .section
|
||||
section = at_css('.section')
|
||||
definition = at_css('.definition')
|
||||
definition['id'] = section['id']
|
||||
section.replace(section.children)
|
||||
|
||||
# Format code for it be highlighted
|
||||
css('.highlight-default.notranslate').each do |node|
|
||||
pre = node.at_css('pre')
|
||||
node.replace(pre)
|
||||
# gets rid of the already existing syntax highlighting
|
||||
pre.inner_html = pre.inner_text
|
||||
pre['class'] = 'language-python'
|
||||
pre['data-language'] = "python"
|
||||
end
|
||||
|
||||
# change descriptions of functions/attributes to blockquote
|
||||
css('.line-block').each do |node|
|
||||
node.name = 'blockquote'
|
||||
end
|
||||
|
||||
# change functions
|
||||
css('.definition').each do |d|
|
||||
|
||||
# the header is the function/attribute name. It might look something like
|
||||
# this:
|
||||
# pygame.image.load()
|
||||
# It'll end up being something like this:
|
||||
# pygame.image.load(filename) -> Surface
|
||||
# pygame.image.load(fileobj, namehint="") -> Surface
|
||||
|
||||
header = d.at_css('dt.title')
|
||||
if d['class'].include?('class') or d['class'].include?('module')
|
||||
header.name = 'h1'
|
||||
@section = header.content.strip
|
||||
else
|
||||
header.name = 'h3'
|
||||
end
|
||||
# save the original header
|
||||
initial_header = header.content.strip
|
||||
# save the real name for the entries
|
||||
header['data-name'] = initial_header
|
||||
# empty the header
|
||||
if header.name == 'h3'
|
||||
header.inner_html = ''
|
||||
end
|
||||
# to replace it with the signatures
|
||||
next_el = header.next_element
|
||||
signatures = next_el.css('.signature')
|
||||
signatures.each do |sig|
|
||||
sig.name = 'code'
|
||||
if header.name == 'h3'
|
||||
sig.parent = header
|
||||
# the signature don't contain pygame.module. I think it's better
|
||||
# to display them, as it avoids confusion with methods (have a
|
||||
# look at the pygame.Rect page)
|
||||
if initial_header.start_with?(@section)
|
||||
sig.content = @section + '.' + sig.text
|
||||
end
|
||||
# seperate the signatures on different lines.
|
||||
header.add_child "<br>"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,35 @@
|
||||
module Docs
|
||||
class Pygame
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
return 'pygame'
|
||||
end
|
||||
|
||||
def get_type
|
||||
at_css('h1').content
|
||||
end
|
||||
|
||||
def include_default_entry?
|
||||
return false
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
return ['pygame'] if root_page?
|
||||
|
||||
entries = []
|
||||
css('h1,h2,h3').each do |node|
|
||||
parentclass = node.parent['class']
|
||||
name = node['id']
|
||||
if not name
|
||||
name = node['data-name']
|
||||
elsif parentclass.include?('function') or parentclass.include?('method')
|
||||
name += '()'
|
||||
end
|
||||
name = name.sub('pygame.', '')
|
||||
entries << [name, node['id'], nil]
|
||||
end
|
||||
entries
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,26 @@
|
||||
module Docs
|
||||
class Pygame < UrlScraper
|
||||
|
||||
self.type = 'simple'
|
||||
|
||||
self.release = 'v1.9.4.dev0'
|
||||
|
||||
self.initial_paths = ['py-modindex.html']
|
||||
self.base_url = 'https://www.pygame.org/docs/'
|
||||
self.root_path = 'py-modindex.html'
|
||||
self.initial_paths = []
|
||||
|
||||
self.links = {
|
||||
home: 'https://www.pygame.org/',
|
||||
code: 'https://github.com/pygame/pygame'
|
||||
}
|
||||
|
||||
html_filters.push 'pygame/clean_html', 'pygame/entries'
|
||||
|
||||
options[:only_patterns] = [/ref\//]
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© Pygame Developpers.
|
||||
HTML
|
||||
end
|
||||
end
|
@ -1 +1,26 @@
|
||||
[]
|
||||
[
|
||||
{
|
||||
"name": "Babel",
|
||||
"slug": "babel",
|
||||
"type": "simple",
|
||||
"links": {
|
||||
"home": "https://babeljs.io/",
|
||||
"code": "https://github.com/babel/babel"
|
||||
},
|
||||
"release": "6.26.1",
|
||||
"mtime": 1526910957,
|
||||
"db_size": 389782
|
||||
},
|
||||
{
|
||||
"name": "Pygame",
|
||||
"slug": "pygame",
|
||||
"type": "simple",
|
||||
"links": {
|
||||
"home": "https://www.pygame.org/",
|
||||
"code": "https://github.com/pygame/pygame"
|
||||
},
|
||||
"release": "v1.9.4.dev0",
|
||||
"mtime": 1527168193,
|
||||
"db_size": 616740
|
||||
}
|
||||
]
|
After Width: | Height: | Size: 6.6 KiB |
After Width: | Height: | Size: 10 KiB |
Loading…
Reference in new issue