Skip to content

Commit ae63752

Browse files
committed
add comments for yard docs
1 parent d828085 commit ae63752

9 files changed

+145
-69
lines changed

exe/ci_system_check.rb

-64
This file was deleted.

lib/arduino_ci/arduino_cmd.rb

+38-3
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,28 @@ class ArduinoCmd
99
# @param name [String] What the flag will be called (prefixed with 'flag_')
1010
# @return [void]
1111
# @macro [attach] flag
12+
# The text of the command line flag for $1
1213
# @!attribute [r] flag_$1
13-
# @return String $2 the text of the command line flag
14+
# @return [String] the text of the command line flag (`$2` in this case)
1415
def self.flag(name, text = nil)
1516
text = "(flag #{name} not defined)" if text.nil?
1617
self.class_eval("def flag_#{name};\"#{text}\";end")
1718
end
1819

19-
attr_accessor :installation
20+
# the path to the Arduino executable
21+
# @return [String]
2022
attr_accessor :base_cmd
2123

24+
# part of a workaround for https://github.com/arduino/Arduino/issues/3535
2225
attr_reader :library_is_indexed
26+
27+
# @return [String] STDOUT of the most recently-run command
2328
attr_reader :last_out
29+
30+
# @return [String] STDERR of the most recently-run command
2431
attr_reader :last_err
32+
33+
# @return [String] the most recently-run command
2534
attr_reader :last_msg
2635

2736
# set the command line flags (undefined for now).
@@ -43,6 +52,9 @@ def initialize
4352
@last_msg = ""
4453
end
4554

55+
# Convert a preferences dump into a flat hash
56+
# @param arduino_output [String] The raw Arduino executable output
57+
# @return [Hash] preferences as a hash
4658
def parse_pref_string(arduino_output)
4759
lines = arduino_output.split("\n").select { |l| l.include? "=" }
4860
ret = lines.each_with_object({}) do |e, acc|
@@ -53,17 +65,21 @@ def parse_pref_string(arduino_output)
5365
ret
5466
end
5567

68+
# @return [String] the path to the Arduino libraries directory
5669
def _lib_dir
5770
"<lib dir not defined>"
5871
end
5972

60-
# fetch preferences to a string
73+
# fetch preferences in their raw form
74+
# @return [String] Preferences as a set of lines
6175
def _prefs_raw
6276
resp = run_and_capture(flag_get_pref)
6377
return nil unless resp[:success]
6478
resp[:out]
6579
end
6680

81+
# Get the Arduino preferences, from cache if possible
82+
# @return [Hash] The full set of preferences
6783
def prefs
6884
prefs_raw = _prefs_raw unless @prefs_fetched
6985
return nil if prefs_raw.nil?
@@ -72,12 +88,16 @@ def prefs
7288
end
7389

7490
# get a preference key
91+
# @param key [String] The preferences key to look up
92+
# @return [String] The preference value
7593
def get_pref(key)
7694
data = @prefs_fetched ? @prefs_cache : prefs
7795
data[key]
7896
end
7997

8098
# underlying preference-setter.
99+
# @param key [String] The preference name
100+
# @param value [String] The value to set to
81101
# @return [bool] whether the command succeeded
82102
def _set_pref(key, value)
83103
run_and_capture(flag_set_pref, "#{key}=#{value}", flag_save_prefs)[:success]
@@ -141,6 +161,8 @@ def run_wrap(*args, **kwargs)
141161
# check whether a board is installed
142162
# we do this by just selecting a board.
143163
# the arduino binary will error if unrecognized and do a successful no-op if it's installed
164+
# @param boardname [String] The board to test
165+
# @return [bool] Whether the board is installed
144166
def board_installed?(boardname)
145167
run_and_capture(flag_use_board, boardname)[:success]
146168
end
@@ -176,23 +198,30 @@ def install_library(library_name)
176198
end
177199

178200
# generate the (very likely) path of a library given its name
201+
# @param library_name [String] The name of the library
202+
# @return [String] The fully qualified library name
179203
def library_path(library_name)
180204
File.join(_lib_dir, library_name)
181205
end
182206

183207
# update the library index
208+
# @return [bool] Whether the update succeeded
184209
def update_library_index
185210
# install random lib so the arduino IDE grabs a new library index
186211
# see: https://github.com/arduino/Arduino/issues/3535
187212
install_library("USBHost")
188213
end
189214

190215
# use a particular board for compilation
216+
# @param boardname [String] The board to use
217+
# @return [bool] whether the command succeeded
191218
def use_board(boardname)
192219
run_and_capture(flag_use_board, boardname, flag_save_prefs)[:success]
193220
end
194221

195222
# use a particular board for compilation, installing it if necessary
223+
# @param boardname [String] The board to use
224+
# @return [bool] whether the command succeeded
196225
def use_board!(boardname)
197226
return true if use_board(boardname)
198227
boardfamily = boardname.split(":")[0..1].join(":")
@@ -201,6 +230,8 @@ def use_board!(boardname)
201230
use_board(boardname)
202231
end
203232

233+
# @param path [String] The sketch to verify
234+
# @return [bool] whether the command succeeded
204235
def verify_sketch(path)
205236
ext = File.extname path
206237
unless ext.casecmp(".ino").zero?
@@ -217,6 +248,8 @@ def verify_sketch(path)
217248

218249
# ensure that the given library is installed, or symlinked as appropriate
219250
# return the path of the prepared library, or nil
251+
# @param path [String] library to use
252+
# @return [String] the path of the installed library
220253
def install_local_library(path)
221254
realpath = File.expand_path(path)
222255
library_name = File.basename(realpath)
@@ -244,6 +277,8 @@ def install_local_library(path)
244277
destination_path
245278
end
246279

280+
# @param installed_library_path [String] The library to query
281+
# @return [Array<String>] Example sketch files
247282
def library_examples(installed_library_path)
248283
example_path = File.join(installed_library_path, "examples")
249284
examples = Pathname.new(example_path).children.select(&:directory?).map(&:to_path).map(&File.method(:basename))

lib/arduino_ci/arduino_cmd_linux.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def initialize
2222
@display_mgr = DisplayManager::instance
2323
end
2424

25-
# fetch preferences to a hash
25+
# fetch preferences in their raw form
26+
# @return [String] Preferences as a set of lines
2627
def _prefs_raw
2728
start = Time.now
2829
resp = run_and_capture(flag_get_pref)
@@ -31,6 +32,8 @@ def _prefs_raw
3132
resp[:out]
3233
end
3334

35+
# implementation for Arduino library dir location
36+
# @return [String] the path to the Arduino libraries directory
3437
def _lib_dir
3538
File.join(get_pref("sketchbook.path"), "libraries")
3639
end
@@ -66,11 +69,14 @@ def _set_pref(key, value)
6669
# check whether a board is installed
6770
# we do this by just selecting a board.
6871
# the arduino binary will error if unrecognized and do a successful no-op if it's installed
72+
# @param boardname [String] The name of the board
73+
# @return [bool]
6974
def board_installed?(boardname)
7075
run_with_gui_guess(" about board not installed", flag_use_board, boardname)
7176
end
7277

7378
# use a particular board for compilation
79+
# @param boardname [String] The name of the board
7480
def use_board(boardname)
7581
run_with_gui_guess(" about board not installed", flag_use_board, boardname, flag_save_prefs)
7682
end

lib/arduino_ci/arduino_cmd_linux_builder.rb

+4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ class ArduinoCmdLinuxBuilder < ArduinoCmd
1414
flag :install_library, "--install-library" # apparently doesn't exist
1515
flag :verify, "-compile"
1616

17+
# linux-specific implementation
18+
# @return [String] The path to the library dir
1719
def _lib_dir
1820
File.join(get_pref("sketchbook.path"), "libraries")
1921
end
2022

2123
# run the arduino command
24+
# @param [Array<String>] Arguments for the run command
25+
# @return [bool] Whether the command succeeded
2226
def _run(*args, **kwargs)
2327
Host.run(*args, **kwargs)
2428
end

lib/arduino_ci/arduino_installation.rb

+7
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,21 @@ module ArduinoCI
1212
class ArduinoInstallation
1313

1414
class << self
15+
# @return [String] The location where a forced install will go
1516
def force_install_location
1617
File.join(ENV['HOME'], 'arduino_ci_ide')
1718
end
1819

1920
# attempt to find a workable Arduino executable across platforms
21+
# @return [ArduinoCI::ArduinoCmd] an instance of the command
2022
def autolocate
2123
case Host.os
2224
when :osx then autolocate_osx
2325
when :linux then autolocate_linux
2426
end
2527
end
2628

29+
# @return [ArduinoCI::ArduinoCmdOSX] an instance of a command
2730
def autolocate_osx
2831
osx_root = "/Applications/Arduino.app/Contents"
2932
old_way = false
@@ -51,6 +54,7 @@ def autolocate_osx
5154
ret
5255
end
5356

57+
# @return [ArduinoCI::ArduinoCmdLinux] an instance of a command
5458
def autolocate_linux
5559
if USE_BUILDER
5660
builder_name = "arduino-builder"
@@ -87,6 +91,7 @@ def autolocate_linux
8791
end
8892

8993
# Attempt to find a workable Arduino executable across platforms, and install it if we don't
94+
# @return [ArduinoCI::ArduinoCmd] an instance of a command
9095
def autolocate!
9196
candidate = autolocate
9297
return candidate unless candidate.nil?
@@ -96,6 +101,8 @@ def autolocate!
96101
autolocate
97102
end
98103

104+
# Forcibly install Arduino from the web
105+
# @return [bool] Whether the command succeeded
99106
def force_install
100107
case Host.os
101108
when :linux

0 commit comments

Comments
 (0)