mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Add date-fns documentation (2.29.2)
This commit is contained in:
parent
2045567b0d
commit
f7aead95e4
9 changed files with 189 additions and 0 deletions
1
Gemfile
1
Gemfile
|
@ -39,6 +39,7 @@ group :development do
|
|||
end
|
||||
|
||||
group :docs do
|
||||
gem 'redcarpet'
|
||||
gem 'progress_bar', require: false
|
||||
gem 'unix_utils', require: false
|
||||
gem 'tty-pager', require: false
|
||||
|
|
|
@ -77,6 +77,7 @@ GEM
|
|||
rb-fsevent (0.10.3)
|
||||
rb-inotify (0.10.0)
|
||||
ffi (~> 1.0)
|
||||
redcarpet (3.5.1)
|
||||
rr (1.2.1)
|
||||
ruby2_keywords (0.0.5)
|
||||
sass (3.7.4)
|
||||
|
@ -157,6 +158,7 @@ DEPENDENCIES
|
|||
rack-ssl-enforcer
|
||||
rack-test
|
||||
rake
|
||||
redcarpet
|
||||
rr
|
||||
sass
|
||||
sinatra
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
[
|
||||
[
|
||||
"2022-09-06",
|
||||
"New documentation: <a href=\"/date_fns/\">date-fns</a>"
|
||||
],
|
||||
[
|
||||
"2022-08-27",
|
||||
"New documentations: <a href=\"/sanctuary/\">Sanctuary</a>, <a href=\"/requests/\">Requests</a>, <a href=\"/axios/\">Axios</a>"
|
||||
|
|
|
@ -236,6 +236,11 @@ credits = [
|
|||
'2012 the Dart project authors',
|
||||
'CC BY-SA',
|
||||
'https://creativecommons.org/licenses/by-sa/4.0/'
|
||||
], [
|
||||
'date-fns',
|
||||
'2021 Sasha Koss and Lesha Koss',
|
||||
'MIT',
|
||||
'https://raw.githubusercontent.com/date-fns/date-fns/main/LICENSE.md'
|
||||
], [
|
||||
'Deno',
|
||||
'2018–2022 the Deno authors',
|
||||
|
|
|
@ -26,6 +26,18 @@ Or run the following commands in your terminal:
|
|||
curl https://storage.googleapis.com/dart-archive/channels/stable/release/$RELEASE/api-docs/dartdocs-gen-api-zip > dartApi.zip; \
|
||||
unzip dartApi.zip; mv gen-dartdocs docs/dart~$VERSION
|
||||
```
|
||||
|
||||
## date-fns
|
||||
|
||||
```sh
|
||||
git clone https://github.com/date-fns/date-fns docs/date_fns
|
||||
cd docs/date_fns
|
||||
git checkout v2.29.2
|
||||
yarn install
|
||||
node scripts/build/docs.js
|
||||
ls tmp/docs.json
|
||||
```
|
||||
|
||||
## Django
|
||||
|
||||
Go to https://docs.djangoproject.com/, select the version from the
|
||||
|
|
163
lib/docs/scrapers/date_fns.rb
Executable file
163
lib/docs/scrapers/date_fns.rb
Executable file
|
@ -0,0 +1,163 @@
|
|||
module Docs
|
||||
class DateFns < FileScraper
|
||||
self.name = 'date-fns'
|
||||
self.slug = 'date_fns'
|
||||
self.type = 'simple'
|
||||
self.links = {
|
||||
home: 'https://date-fns.org/',
|
||||
code: 'https://github.com/date-fns/date-fns'
|
||||
}
|
||||
self.release = '2.29.2'
|
||||
self.base_url = "https://date-fns.org/v#{self.release}/docs/"
|
||||
|
||||
# https://github.com/date-fns/date-fns/blob/main/LICENSE.md
|
||||
options[:attribution] = <<-HTML
|
||||
© 2021 Sasha Koss and Lesha Koss<br>
|
||||
Licensed under the MIT License.
|
||||
HTML
|
||||
|
||||
def build_pages
|
||||
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, fenced_code_blocks: true, tables: true)
|
||||
|
||||
md_files = %w(esm.md fp.md gettingStarted.md i18n.md i18nContributionGuide.md release.md timeZones.md unicodeTokens.md upgradeGuide.md webpack.md)
|
||||
md_files.each do |md_file|
|
||||
md_string = request_one("docs/#{md_file}").body
|
||||
md_file = 'index.md' if md_file == 'gettingStarted.md'
|
||||
name = md_string.match(/^#([^\n]+)/)[1]
|
||||
path = md_file.sub '.md', ''
|
||||
page = {
|
||||
path: path,
|
||||
store_path: "#{path}.html",
|
||||
output: markdown.render(md_string),
|
||||
entries: [Entry.new(name, path, 'General')]
|
||||
}
|
||||
yield page
|
||||
end
|
||||
|
||||
docs = JSON.parse(request_one('tmp/docs.json').body)
|
||||
docs.each do |type, features|
|
||||
features.each do |feature|
|
||||
name = feature['title']
|
||||
feature_id = feature['urlId']
|
||||
next if feature_id.start_with?('fp/')
|
||||
next if feature['type'] != 'jsdoc'
|
||||
# fix description table on https://date-fns.org/v2.29.2/docs/parse
|
||||
feature['content']['description'].sub! "\n| Unit", "\n\n| Unit"
|
||||
feature['content']['description'].sub! "\nNotes:\n", "\n\nNotes:\n"
|
||||
page = {
|
||||
path: name,
|
||||
store_path: "#{feature_id}.html",
|
||||
output: ERB.new(PAGE_ERB).result(binding),
|
||||
entries: [Entry.new(name, feature_id, type)]
|
||||
}
|
||||
yield page
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
PAGE_ERB = <<-HTML.strip_heredoc
|
||||
<h1><%= feature['title'] %></h1>
|
||||
<p><%= feature['description'] %></p>
|
||||
|
||||
<h2>Description</h2>
|
||||
<p><%= markdown.render feature['content']['description'] %></p>
|
||||
|
||||
<% if feature['usage'] %>
|
||||
<h2>Usage</h2>
|
||||
<% feature['usage'].each do |_, usage| %>
|
||||
<pre data-language="javascript"><%= '// ' + usage['title'] + '\n' %><%= usage['code'] %></pre>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if feature['syntax'] %>
|
||||
<h2>Syntax</h2>
|
||||
<pre data-language="javascript"><%= feature['syntax'] %></pre>
|
||||
<% end %>
|
||||
|
||||
<% if feature['content']['properties'] %>
|
||||
<h2>Properties</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<% feature['content']['properties'].each do |param| %>
|
||||
<tr>
|
||||
<td><code><%= param['name'] %></code></td>
|
||||
<td><code><%= param['type']['names'].join ' ' %></code></td>
|
||||
<td><%= markdown.render param['description'] || '' %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
<% if feature['content']['params'] %>
|
||||
<h2>Arguments</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<% feature['content']['params'].each do |param| %>
|
||||
<tr>
|
||||
<td><code><%= param['name'] %></code></td>
|
||||
<td><%= markdown.render param['description'] || '' %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
<% if feature['content']['returns'] %>
|
||||
<h2>Returns</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<% feature['content']['returns'].each do |param| %>
|
||||
<tr>
|
||||
<td><%= markdown.render param['description'] || '' %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
<% if feature['content']['exceptions'] %>
|
||||
<h2>Exceptions</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<% feature['content']['exceptions'].each do |param| %>
|
||||
<tr>
|
||||
<td><code><%= param['type']['names'].join ' ' %></code></td>
|
||||
<td><%= markdown.render param['description'] || '' %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
<% if feature['content']['examples'] %>
|
||||
<h2>Examples</h2>
|
||||
<% feature['content']['examples'].each do |example| %>
|
||||
<pre data-language="javascript"><%= example %></pre>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<div class="_attribution">
|
||||
<p class="_attribution-p">
|
||||
<%= options[:attribution] %>
|
||||
<br>
|
||||
<a href="<%= self.base_url %><%= feature_id %>" class="_attribution-link">
|
||||
<%= self.base_url %><%= feature_id %>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
HTML
|
||||
|
||||
def get_latest_version(opts)
|
||||
get_latest_github_release('date-fns', 'date-fns', opts)
|
||||
end
|
||||
end
|
||||
end
|
BIN
public/icons/docs/date_fns/16.png
Normal file
BIN
public/icons/docs/date_fns/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 849 B |
BIN
public/icons/docs/date_fns/16@2x.png
Normal file
BIN
public/icons/docs/date_fns/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
2
public/icons/docs/date_fns/SOURCE
Normal file
2
public/icons/docs/date_fns/SOURCE
Normal file
|
@ -0,0 +1,2 @@
|
|||
https://date-fns.org/static/favicon-16x16.png
|
||||
https://date-fns.org/static/favicon-32x32.png
|
Loading…
Reference in a new issue