-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: improve functions reference (#1049)
Co-authored-by: Yiran <cuiyiran3@gmail.com>
- Loading branch information
1 parent
bb4238f
commit 06d70ae
Showing
24 changed files
with
9,878 additions
and
383 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,5 @@ jobs: | |
config_file: .markdownlint.yaml | ||
- name: Check typos | ||
uses: crate-ci/typos@master | ||
with: | ||
config: .typo.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[files] | ||
extend-exclude = ["*/**/df-functions.md"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/ruby | ||
## A script to update functions in nightly references | ||
## Usage: ruby misc/update_functions.rb [nightly | v0.x] | ||
# encoding: utf-8 | ||
require 'net/http' | ||
|
||
scalar_functions = { | ||
:name => "DataFusion Scalar Functions", | ||
:url => "https://raw.githubusercontent.com/apache/datafusion/main/docs/source/user-guide/sql/scalar_functions.md" | ||
} | ||
agg_functions = { | ||
:name => "DataFusion Aggregate Functions", | ||
:url => "https://raw.githubusercontent.com/apache/datafusion/main/docs/source/user-guide/sql/aggregate_functions.md" | ||
} | ||
window_functions = { | ||
:name => "DataFusion Window Functions", | ||
:url => "https://raw.githubusercontent.com/apache/datafusion/main/docs/source/user-guide/sql/window_functions.md" | ||
} | ||
|
||
## Apache DataFusion functions | ||
datafusion_functions = [scalar_functions, agg_functions, window_functions] | ||
|
||
|
||
def process_headlines(line) | ||
## Add a level of headlines | ||
if line =~ /^\s*(#+)\s/ | ||
replacement = "#{$1}#" | ||
## We don't want to render the function names in right menu bar | ||
replacement += "#" if replacement.length >= 4 | ||
line.gsub! $1, replacement | ||
end | ||
line | ||
end | ||
|
||
def fix_links(line) | ||
## Fix link: #a_b_c -> #a-b-c | ||
line.gsub!(/(#[a-zA-Z0-9_]+)\)/) { |match| match.gsub("_", "-") } | ||
## Fix link: a_b_c.md -> #a-b-c | ||
line.gsub!(/\]\(([a-zA-Z0-9_]+\.md)\)/) { |match| | ||
match.gsub("_", "-").gsub(".md", "").gsub("](", "](#") | ||
} | ||
|
||
line | ||
end | ||
|
||
|
||
File.open("temp.md", "w") do |f| | ||
f.puts("# DataFusion Functions\n\n") | ||
f.puts("This page is generated from the Apache DataFusion project's documents:") | ||
|
||
for doc in datafusion_functions | ||
name = doc[:name] | ||
url = doc[:url] | ||
markdown = " * [#{name}](#{url})" | ||
f.puts markdown | ||
end | ||
|
||
f.puts | ||
|
||
for doc in datafusion_functions | ||
uri = URI(doc[:url]) | ||
markdown = Net::HTTP.get(uri).force_encoding(Encoding::UTF_8) | ||
|
||
lines = markdown.split(/\n/) | ||
|
||
lines.map! do |line| | ||
line = process_headlines(line) | ||
line = fix_links(line) | ||
line | ||
end | ||
|
||
f.puts lines.join("\n") | ||
end | ||
end | ||
|
||
target = ARGV[0] || "nightly" | ||
|
||
File.rename "temp.md", "#{target}/en/reference/sql/functions/df-functions.md" | ||
|
||
puts "#{target}/en/reference/sql/functions/df-functions.md updated!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.