DEV: adds --help --no-help options to plugin generator (#6338)

help will add helpful comments in the various generated files
This commit is contained in:
Joffrey JAFFEUX 2018-08-30 12:16:37 +02:00 committed by GitHub
parent acc96abe1a
commit d40d241e72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

View File

@ -10,6 +10,7 @@ class PluginGenerator < Rails::Generators::NamedBase
class_option :stylesheet, type: :boolean, desc: "Generate Stylesheet", default: true
class_option :javascript, type: :boolean, desc: "Generate Javascript initializer", default: true
class_option :scheduled_job, type: :boolean, desc: "Generate scheduled job", default: false
class_option :help, type: :boolean, desc: "Adds help comments in generated files", default: true
def create_scheduled_job_file
return unless @options['scheduled_job']

View File

@ -1,6 +1,10 @@
import { withPluginApi } from "discourse/lib/plugin-api";
function initialize<%= classified_name %>(api) {
<% if @options['help'] %>
// see app/assets/javascripts/discourse/lib/plugin-api
// for the functions available via the api object
<% end %>
}
export default {

View File

@ -13,6 +13,10 @@ enabled_site_setting :<%= underscored_name %>_enabled
PLUGIN_NAME ||= "<%= name %>".freeze
after_initialize do
<% if @options['help'] %>
# see lib/plugin/instance.rb for the methods available in this context
<% end %>
module ::<%= classified_name %>
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME