Skip to content
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

docs: improve functions reference #1049

Merged
merged 15 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ jobs:
config_file: .markdownlint.yaml
- name: Check typos
uses: crate-ci/typos@master
with:
config: .typo.toml
2 changes: 2 additions & 0 deletions .typo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[files]
extend-exclude = ["*/**/df-functions.md"]
80 changes: 80 additions & 0 deletions docs/misc/update_functions.rb
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")
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/df-functions.md"

puts "#{target}/en/reference/sql/df-functions.md updated!"
2 changes: 1 addition & 1 deletion docs/nightly/en/faq-and-others/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Of course, please use the `compact_table` function:
select compact_table("test");
```

There are many [administration functions](/reference/sql/functions#admin-functions) for database management.
There are many [administration functions](/reference/sql/functions/overview#admin-functions) for database management.

### Can GreptimeDB be used to store logs?

Expand Down
180 changes: 0 additions & 180 deletions docs/nightly/en/reference/sql/functions.md

This file was deleted.

Loading