-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add Odin documentation #2687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add Odin documentation #2687
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| module Docs | ||
| class Odin | ||
| class CleanHtmlFilter < Filter | ||
| def call | ||
| @doc = at_css('#pkg') || doc | ||
|
|
||
| css('nav').remove | ||
| doc | ||
| end | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| module Docs | ||
| class Odin | ||
| class EntriesFilter < Docs::EntriesFilter | ||
| def get_name | ||
| title = context[:html_title].gsub(/ \| Odin Programming Language/, "") | ||
| title | ||
| end | ||
|
|
||
| def get_type | ||
| if subpath.start_with?('docs') | ||
| "Documentation" | ||
| elsif subpath.start_with?('spec') | ||
| "Specifications" | ||
| end | ||
| end | ||
|
|
||
| def additional_entries | ||
| entries = [] | ||
| entries | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| module Docs | ||
| class OdinPackages | ||
| class CleanHtmlFilter < Filter | ||
| def call | ||
| @doc = at_css('#pkg') || doc | ||
|
|
||
| css('.pkg-breadcrumb').remove | ||
| css('.a-hidden').remove | ||
| css('.doc-source').remove | ||
| css('.odin-search-wrapper').remove | ||
| css('#pkg-sidebar').remove | ||
| css('#odin-search-info').remove | ||
| css('#odin-search-results').remove | ||
|
|
||
| doc | ||
| end | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| module Docs | ||
| class OdinPackages | ||
| class EntriesFilter < Docs::EntriesFilter | ||
| def get_name | ||
| breadcrumbs = css(".pkg-breadcrumb > ol > li") | ||
| if breadcrumbs | ||
| if breadcrumbs[1] | ||
| breadcrumbs[1].content | ||
| elsif breadcrumbs[0] | ||
| breadcrumbs[0].content | ||
| end | ||
| end | ||
| title = context[:html_title].gsub(/- pkg.odin-lang.org/, "") | ||
| title = title.gsub(/^package /, "") | ||
| title | ||
| end | ||
|
|
||
| def get_type | ||
| breadcrumb_base = css(".pkg-breadcrumb > ol > li") | ||
| doc_directory = css(".doc-directory") | ||
| if breadcrumb_base[0] | ||
| breadcrumb_base[0].content | ||
| elsif doc_directory | ||
| title = context[:html_title].gsub(/ library - pkg.odin-lang.org/, "") | ||
| title | ||
| elsif context[:html_title].starts_with?('package') | ||
| 'Packages' | ||
| else | ||
| 'Docs' | ||
| end | ||
| end | ||
|
|
||
| def additional_entries | ||
| entries = [] | ||
| entries | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| module Docs | ||
| class Odin < UrlScraper | ||
| self.name = 'Odin' | ||
| self.slug = 'odin' | ||
| self.type = 'odin' | ||
| self.release = 'latest' | ||
| self.base_url = 'https://odin-lang.org/' | ||
| self.root_path = 'https://odin-lang.org/' | ||
| self.initial_paths = %w(docs spec) | ||
|
|
||
| self.links = { | ||
| home: 'https://odin-lang.org/', | ||
| code: 'https://github.com/odin-lang/Odin' | ||
| } | ||
|
|
||
| html_filters.push 'odin/entries', 'odin/clean_html' | ||
| options[:download_images] = false | ||
|
|
||
| options[:container] = '.odin-main' | ||
|
|
||
| options[:only_patterns] = [/docs/, /spec/] | ||
| options[:trailing_slash] = false | ||
|
|
||
| options[:skip] = %w( | ||
| docs/examples | ||
| docs/nightly | ||
| docs/odin-book | ||
| docs/spec | ||
| docs/packages | ||
| ) | ||
|
|
||
| options[:attribution] = <<-HTML | ||
| © 2016-#{Date.today.year} Ginger Bill<br> | ||
| Licensed under the 3-clause BSD License. | ||
| HTML | ||
|
|
||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| module Docs | ||
| class OdinPackages < UrlScraper | ||
| self.name = 'Odin Packages' | ||
| self.slug = 'odin_packages' | ||
| self.type = 'odin_packages' | ||
|
Comment on lines
+3
to
+5
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer to have this separate scraper to be merged with the main
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you! This makes a lot of sense. When I was looking, I didn't recognize there were parsers with multiple URLs that could be executed in the same scrape (my own skill issue). Thank you for pointing that out! I'll look at those and get that updated! |
||
| self.release = 'latest' | ||
| self.base_url = 'https://pkg.odin-lang.org/' | ||
| self.initial_paths = %w(base core vendor) | ||
|
|
||
| options[:trailing_slash] = false | ||
|
|
||
| self.links = { | ||
| home: 'https://odin-lang.org/', | ||
| code: 'https://github.com/odin-lang/Odin' | ||
| } | ||
|
|
||
| html_filters.push 'odin_packages/entries', 'odin_packages/clean_html' | ||
|
|
||
| options[:download_images] = false | ||
| options[:container] = '.odin-main' | ||
|
|
||
| options[:attribution] = <<-HTML | ||
| © 2016-#{Date.today.year} Ginger Bill<br> | ||
| Licensed under the 3-clause BSD License. | ||
| HTML | ||
|
|
||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| https://github.com/odin-lang/odin-lang.org/blob/master/static/favicon.svg |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| https://github.com/odin-lang/odin-lang.org/blob/master/static/favicon.svg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The license has been changed, see odin-lang/Odin@842cfee.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! I'll get this updated!