discorb 0.2.5 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e27fc8b1d9e527f2ce007c686025f4edc9ca7ee8dda06df91ff48a02034a1dbf
4
- data.tar.gz: 7708d124bd2921941164e178c35714b3cf7d68f19b202a823bc9913688c35495
3
+ metadata.gz: e88541a1d18a1ebd262bae5d91bb38c02d91350e1b2cf698c3f491bf58bb5cfa
4
+ data.tar.gz: dc55e68bea5b74105eb941c8ec50bec6fa6f4bf3dd716a1e505ea6c3ab598725
5
5
  SHA512:
6
- metadata.gz: 8b4d553c7fe030956205058581ed1685a73fcdc1034c250e1c09ca29ef52637d8b85b10bb19edc93d334f0782e7b9a4d4fe4e88976d1f1174286e5f72ca866bb
7
- data.tar.gz: bc6ec15cb5c3592df82e5af2682f690a5ee6649e8a1cf957786bf0886f3b0c3ad76ab6241b606d52380d47b3ccd17f4c7cda71b62b98198ce3470180ec07c753
6
+ metadata.gz: 5c5d884643656bca43b2ee1e448c0860f0235f439875cbad59a89c79b5d98c71d7b3f539ab6150a051b262ebb09551cf8f943c090676f0751d5533596bc5aea8
7
+ data.tar.gz: d4ddfe0faa3c4cdcbc14293216c13017d4c64b7c0f4594e44d5ddb9ab7b9b60ddb4f5acc8a4d06eaec8d1f5e504b13fd43c4f3bc898d787976c617c7509a15dc
@@ -0,0 +1,51 @@
1
+ name: Build YARD with main
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ schedule:
6
+ - cron: "*/8 * * * *"
7
+
8
+ jobs:
9
+ main:
10
+
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Set up Ruby
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: 3.0.2
19
+ bundler-cache: true
20
+ - name: Set up git settings
21
+ run: |
22
+ git config --global user.email "action@github.com"
23
+ git config --global user.name "GitHub Action"
24
+ - name: Clone pages
25
+ env:
26
+ SSH_SECRET: ${{ secrets.SSH }}
27
+ GIT_SSH_COMMAND: ssh -i ~/ssh_secret
28
+ run: |
29
+ echo "$SSH_SECRET" > ~/ssh_secret
30
+ chmod 600 ~/ssh_secret
31
+ git clone git@github.com:discorb-lib/discorb-lib.github.io /tmp/pages
32
+ - name: Install dependencies
33
+ run: |
34
+ bundle config --local with 'docs'
35
+ bundle install
36
+ - name: Generate document
37
+ run: bundle exec rake document
38
+ - name: Push document
39
+ env:
40
+ SSH_SECRET: ${{ secrets.SSH }}
41
+ GIT_SSH_COMMAND: ssh -i ~/ssh_secret
42
+ run: |
43
+ echo "$SSH_SECRET" > ~/ssh_secret
44
+ chmod 600 ~/ssh_secret
45
+ cp -r ./doc/. /tmp/pages
46
+ cd /tmp/pages
47
+ git add -A
48
+ git commit -m "Update: Update document for ${{ github.sha }} by cron"
49
+ git update-ref -d refs/remotes/origin/user
50
+ git push origin main -f
51
+ continue-on-error: true
data/.gitignore CHANGED
@@ -35,7 +35,7 @@ build-iPhoneSimulator/
35
35
  ## Documentation cache and generated files:
36
36
  /.yardoc/
37
37
  /_yardoc/
38
- /doc/
38
+ # /doc/
39
39
  /rdoc/
40
40
 
41
41
  ## Environment normalization:
@@ -54,4 +54,8 @@ build-iPhoneSimulator/
54
54
 
55
55
  # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
56
  # .rubocop-https?--*
57
+
58
+ # For documentation generation.
57
59
  tmp-template-replace
60
+ tmp-doc
61
+ doc
data/.yardopts CHANGED
@@ -4,5 +4,5 @@
4
4
  --tag flags:"Flags"
5
5
  --verbose
6
6
  -
7
- docs/*.md
7
+ docs/**/*.md
8
8
  Changelog.md
data/Changelog.md CHANGED
@@ -73,4 +73,25 @@
73
73
  ## 0.2.5
74
74
 
75
75
  - Add: Add way to add event listener
76
- - Change: Move document to https://discorb-lib.github.io/
76
+ - Change: Move document to https://discorb-lib.github.io/
77
+
78
+ ## 0.3.0
79
+
80
+ - Add: Improve CLI tools
81
+ - Add: Add `discorb init`
82
+ - Change: Change `discord-irb` to `discorb irb`
83
+
84
+ ## 0.3.1
85
+
86
+ - Add: Add `discorb show`
87
+ - Fix: Fix documenting
88
+
89
+ ## 0.4.0
90
+
91
+ - Add: Add `discorb setup`
92
+ - Add: Add `discorb run`
93
+ - Add: Add realtime documentation
94
+
95
+ ## 0.4.1
96
+
97
+ - Add: Add `-s` option to `discorb run`
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- discorb (0.2.5)
5
- async
6
- async-http
7
- async-websocket
4
+ discorb (0.4.1)
5
+ async (~> 1.30.1)
6
+ async-http (~> 0.56.5)
7
+ async-websocket (~> 0.19.0)
8
8
  mime-types (~> 3.3)
9
9
 
10
10
  GEM
@@ -34,11 +34,11 @@ GEM
34
34
  fiber-local (1.0.0)
35
35
  mime-types (3.3.1)
36
36
  mime-types-data (~> 3.2015)
37
- mime-types-data (3.2021.0704)
38
- nio4r (2.5.7)
37
+ mime-types-data (3.2021.0901)
38
+ nio4r (2.5.8)
39
39
  protocol-hpack (1.4.2)
40
40
  protocol-http (0.22.5)
41
- protocol-http1 (0.14.1)
41
+ protocol-http1 (0.14.2)
42
42
  protocol-http (~> 0.22)
43
43
  protocol-http2 (0.14.2)
44
44
  protocol-hpack (~> 1.4)
@@ -54,6 +54,7 @@ GEM
54
54
 
55
55
  PLATFORMS
56
56
  x86-mingw32
57
+ x86_64-linux
57
58
 
58
59
  DEPENDENCIES
59
60
  discorb!
data/Rakefile CHANGED
@@ -1,30 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
+ require_relative "lib/discorb/utils/colored_puts"
4
5
  task default: %i[]
5
6
 
7
+ # @!visibility private
6
8
  def get_version
7
9
  require_relative "lib/discorb/common"
8
- latest_commit = `git log --oneline`.force_encoding("utf-8").split("\n")[0]
9
- version = Discorb::VERSION
10
- unless latest_commit.downcase.include?("update version")
11
- version += "-dev"
10
+ tag = `git tag --points-at HEAD`.force_encoding("utf-8").strip
11
+ if tag.empty?
12
+ version = "main"
13
+ else
14
+ version = Discorb::VERSION
12
15
  end
13
16
  version
14
17
  end
15
18
 
16
- def gputs(text)
17
- puts "\e[90m#{text}\e[m"
18
- end
19
-
20
- def sputs(text)
21
- puts "\e[92m#{text}\e[m"
22
- end
23
-
19
+ desc "Build emoji_table.rb"
24
20
  task :emoji_table do
25
21
  require_relative "lib/discorb"
26
22
 
27
- gputs "Building emoji_table.rb"
23
+ iputs "Building emoji_table.rb"
28
24
  res = {}
29
25
  Discorb::EmojiTable::DISCORD_TO_UNICODE.each do |discord, unicode|
30
26
  res[unicode] ||= []
@@ -47,11 +43,12 @@ task :emoji_table do
47
43
  sputs "Successfully made emoji_table.rb"
48
44
  end
49
45
 
46
+ desc "Format files"
50
47
  task :format do
51
48
  Dir.glob("**/*.rb").each do |file|
52
49
  next if file.start_with?("vendor")
53
50
 
54
- gputs "Formatting #{file}"
51
+ iputs "Formatting #{file}"
55
52
  `rufo ./#{file}`
56
53
  content = ""
57
54
  File.open(file, "rb") do |f|
@@ -63,27 +60,37 @@ task :format do
63
60
  end
64
61
  end
65
62
  end
63
+
64
+ desc "Generate document and replace"
66
65
  namespace :document do
67
66
  version = get_version
67
+
68
+ desc "Just generate document"
68
69
  task :yard do
69
- sh "yardoc -o doc/#{version}"
70
+ sh "bundle exec yardoc -o doc/#{version}"
70
71
  end
72
+
73
+ desc "Replace files"
71
74
  namespace :replace do
72
75
  require "fileutils"
76
+
77
+ desc "Replace CSS"
73
78
  task :css do
74
- gputs "Replacing css"
79
+ iputs "Replacing css"
75
80
  Dir.glob("template-replace/files/**/*.*")
76
81
  .map { |f| f.delete_prefix("template-replace/files") }.each do |file|
77
82
  FileUtils.cp("template-replace/files" + file, "doc/#{version}/#{file}")
78
83
  end
79
84
  sputs "Successfully replaced css"
80
85
  end
86
+
87
+ desc "Replace HTML"
81
88
  task :html do
82
89
  require_relative "template-replace/scripts/sidebar.rb"
83
90
  require_relative "template-replace/scripts/version.rb"
84
91
  require_relative "template-replace/scripts/index.rb"
85
92
  require_relative "template-replace/scripts/yard_replace.rb"
86
- gputs "Resetting changes"
93
+ iputs "Resetting changes"
87
94
  Dir.glob("doc/#{version}/**/*.html") do |f|
88
95
  next if (m = f.match(/[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?/)) && m[0] != version
89
96
 
@@ -91,21 +98,23 @@ namespace :document do
91
98
  content.gsub!(/<!--od-->[\s\S]*<!--eod-->/, "")
92
99
  File.write(f, content)
93
100
  end
94
- gputs "Adding version tab"
101
+ iputs "Adding version tab"
95
102
  %w[file_list class_list method_list].each do |f|
96
103
  replace_sidebar("doc/#{version}/#{f}.html")
97
104
  end
98
105
 
99
- gputs "Building version tab"
100
- build_version_sidebar("doc/#{version}")
101
- gputs "Replacing _index.html"
106
+ iputs "Building version tab"
107
+ build_version_sidebar("doc/#{version}", version)
108
+ iputs "Replacing _index.html"
102
109
  replace_index("doc/#{version}", version)
103
- gputs "Replacing YARD credits"
110
+ iputs "Replacing YARD credits"
104
111
  yard_replace("doc/#{version}", version)
105
- gputs "Successfully replaced htmls"
112
+ iputs "Successfully replaced htmls"
106
113
  end
114
+
115
+ desc "Replace EOL"
107
116
  task :eol do
108
- gputs "Replacing CRLF with LF"
117
+ iputs "Replacing CRLF with LF"
109
118
  Dir.glob("doc/**/*.*") do |file|
110
119
  next unless File.file?(file)
111
120
 
@@ -122,20 +131,36 @@ namespace :document do
122
131
  end
123
132
  end
124
133
  task :replace => %i[replace:css replace:html replace:eol]
134
+
135
+ desc "Build all versions"
125
136
  task :build_all do
126
137
  require "fileutils"
127
- gputs "Building all versions"
138
+
139
+ class Bundler::Definition
140
+ def validate_platforms!
141
+ # noop
142
+ end
143
+ end
144
+
145
+ iputs "Building all versions"
146
+ FileUtils.rm_rf("doc") rescue nil
128
147
  FileUtils.cp_r("./template-replace/.", "./tmp-template-replace")
148
+ Rake::Task["document:yard"].execute
149
+ Rake::Task["document:replace:html"].execute
150
+ Rake::Task["document:replace:css"].execute
151
+ Rake::Task["document:replace:eol"].execute
129
152
  tags = `git tag`.force_encoding("utf-8").split("\n")
130
153
  tags.each do |tag|
131
154
  sh "git checkout #{tag} -f"
132
- gputs "Building #{tag}"
155
+ iputs "Building #{tag}"
133
156
  FileUtils.cp_r("./tmp-template-replace/.", "./template-replace")
134
157
  version = tag.delete_prefix("v")
135
158
  Rake::Task["document:yard"].execute
136
159
  Rake::Task["document:replace:html"].execute
137
160
  Rake::Task["document:replace:css"].execute
138
161
  Rake::Task["document:replace:eol"].execute
162
+ FileUtils.cp_r("./doc/.", "./tmp-doc")
163
+ FileUtils.rm_rf("doc")
139
164
  end
140
165
  version = "."
141
166
  Rake::Task["document:yard"].execute
@@ -143,11 +168,19 @@ namespace :document do
143
168
  Rake::Task["document:replace:css"].execute
144
169
  Rake::Task["document:replace:eol"].execute
145
170
  sh "git switch main -f"
171
+ FileUtils.cp_r("./tmp-doc/.", "./doc")
146
172
  sputs "Successfully built all versions"
173
+ rescue => e
174
+ sh "git switch main -f"
175
+ raise e
147
176
  end
177
+
178
+ desc "Push to discorb-lib/discorb-lib.github.io"
148
179
  task :push do
149
- gputs "Pushing documents"
180
+ iputs "Pushing documents"
150
181
  Dir.chdir("doc") do
182
+ sh "git init"
183
+ sh "git remote add origin git@github.com:discorb-lib/discorb-lib.github.io"
151
184
  sh "git add ."
152
185
  sh "git commit -m \"Update: Update document\""
153
186
  sh "git push -f"
data/discorb.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.metadata["homepage_uri"] = spec.homepage
19
19
  spec.metadata["source_code_uri"] = "https://github.com/discorb-lib/discorb"
20
- spec.metadata["changelog_uri"] = "https://github.com/discorb-lib/discorb/blob/main/Changelog.md"
20
+ spec.metadata["changelog_uri"] = "https://discorb-lib.github.io/file.Changelog.html"
21
21
  spec.metadata["documentation_uri"] = "https://discorb-lib.github.io"
22
22
 
23
23
  # Specify which files should be added to the gem when it is released.
@@ -30,9 +30,9 @@ Gem::Specification.new do |spec|
30
30
  spec.require_paths = ["lib"]
31
31
 
32
32
  # Uncomment to register a new dependency of your gem
33
- spec.add_dependency "async"
34
- spec.add_dependency "async-http"
35
- spec.add_dependency "async-websocket"
33
+ spec.add_dependency "async", "~> 1.30.1"
34
+ spec.add_dependency "async-http", "~> 0.56.5"
35
+ spec.add_dependency "async-websocket", "~> 0.19.0"
36
36
 
37
37
  spec.add_dependency "mime-types", "~> 3.3"
38
38
  # For more information and examples about making a new gem, checkout our
@@ -10,7 +10,13 @@ From: [Discord API docs](https://discord.com/developers/docs/interactions/applic
10
10
 
11
11
  ## How do I register an application command?
12
12
 
13
- Use {Discorb::Command::Handler.slash}, {Discorb::Command::Handler.slash_group} for slash commands, {Discorb::Command::Handler.user_command} for user menu commands, and {Discorb::Command::Handler.message_command} for message menu commands.
13
+ Write to a your script:
14
+ - {Discorb::Command::Handler.slash}, {Discorb::Command::Handler.slash_group} for slash commands,
15
+ - {Discorb::Command::Handler.user_command} for user menu commands,
16
+ - {Discorb::Command::Handler.message_command} for message menu commands.
17
+
18
+ And then run `discorb setup` to register your application commands.
19
+ {file:docs/cli/setup.md Learn more about `discorb setup`}.
14
20
 
15
21
  ### Note
16
22
 
data/docs/cli/init.md ADDED
@@ -0,0 +1,55 @@
1
+ # @title CLI: discorb init
2
+
3
+ # discorb init
4
+
5
+ This command will create a new project in the directory.
6
+
7
+ ## Usage
8
+
9
+ ```bash
10
+ discorb init [options] [dir]
11
+ ```
12
+
13
+ ## Options
14
+
15
+ ### `dir`
16
+
17
+ The directory to create the project in.
18
+ Defaults to the current directory.
19
+ If the directory exists and is not empty, an error is returned.
20
+ You can use `--force` to overwrite an existing directory.
21
+
22
+ ### `--[no-]bundle`
23
+
24
+ Whether to use bundle.
25
+ If true, the command will create Gemfile and execute `bundle install`.
26
+ Default to true.
27
+
28
+ ### `--[no-]git`
29
+
30
+ Whether to initialize git.
31
+ If true, the command will initialize git and commit the initial files with commit message `Initial commit`.
32
+ Use `git commit --amend -m "..."` to change the commit message.
33
+ Default to true.
34
+
35
+ ### `-t`, `--token`
36
+
37
+ The name of token environment variable.
38
+ Default to TOKEN.
39
+
40
+ ### `-f`, `--force`
41
+
42
+ Whether to overwrite an existing directory.
43
+ Default to false.
44
+
45
+ ## File structure
46
+
47
+ The following files will be created:
48
+
49
+ | File | Description |
50
+ | ---- | ----------- |
51
+ | `.env` | Environment variables. |
52
+ | `.gitignore` | Git ignore file. Won't be created if `--git` is false. |
53
+ | `Gemfile` | Gemfile. Won't be created if `--bundle` is false. |
54
+ | `Gemfile.lock` | Gemfile lock file. Won't be created if `--bundle` is false. |
55
+ | `main.rb` | Main script. |
@@ -1,21 +1,19 @@
1
- # @title discord-irb
1
+ # @title CLI: discorb irb
2
2
 
3
- # discord-irb
3
+ # discorb irb
4
4
 
5
- discord-irb is a command line tool for interacting with the Discord API.
5
+ This command will start an interactive Ruby shell with connected client.
6
6
 
7
7
 
8
8
  ## Usage
9
9
 
10
10
  ```
11
- $ bundle exec discord-irb
11
+ discorb irb [options]
12
12
  ```
13
13
 
14
- To start.
15
-
16
14
  ### Load a token
17
15
 
18
- discord-irb will load a token from...
16
+ discorb irb will load a token from...
19
17
  1. the `DISCORD_BOT_TOKEN` environment variable
20
18
  2. the `DISCORD_TOKEN` environment variable
21
19
  3. `token` file in the current directory(customizable with `-t` option)