diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml
new file mode 100644
index 0000000..b7409d4
--- /dev/null
+++ b/.github/workflows/documentation.yml
@@ -0,0 +1,29 @@
+name: website
+
+on:
+ push:
+ branches: [ master ]
+
+jobs:
+ publish:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Install Crystal
+ uses: crystal-lang/install-crystal@v1
+ with:
+ crystal: nightly
+ - name: Check out repository code
+ uses: actions/checkout@v2
+ - name: Install dependencies
+ run: shards install
+ - name: Generate documentation
+ run: crystal docs
+ -
+ name: Deploy to GitHub Pages
+ if: success()
+ uses: crazy-max/ghaction-github-pages@v2
+ with:
+ target_branch: gh-pages
+ build_dir: docs
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/src/mechanize/cookie.cr b/src/mechanize/cookie.cr
index 0b3e44d..3c8c6aa 100644
--- a/src/mechanize/cookie.cr
+++ b/src/mechanize/cookie.cr
@@ -1,5 +1,6 @@
-# TODO: want to add methods with safe way like Ruby's refinement.
+# TODO: want to property's without open HTTP::Cookie class.
+# This class represents http cookie.
# open HTTP::Cookie class to add origin property.
# origin property represents the origin of the resource.
# if cookie's domain attribute isn't designated,
diff --git a/src/mechanize/errors/element_not_found_error.cr b/src/mechanize/errors/element_not_found_error.cr
index fd35a4a..7456b35 100644
--- a/src/mechanize/errors/element_not_found_error.cr
+++ b/src/mechanize/errors/element_not_found_error.cr
@@ -1,5 +1,6 @@
require "./base_error"
+# This error means matched elements are not found by *_with method.
class Mechanize::ElementNotFoundError < Mechanize::Error
getter element : Symbol
getter conditions : String
diff --git a/src/mechanize/file.cr b/src/mechanize/file.cr
index 02539b4..9ec0b40 100644
--- a/src/mechanize/file.cr
+++ b/src/mechanize/file.cr
@@ -1,9 +1,15 @@
require "http/client"
class Mechanize
- class File
- # property :body, :filename
- property :body, :code, uri, :response
+ abstract class File
+ # property :filename
+
+ # returns http response body
+ getter body : String
+ # returns http status code
+ getter code : Int32
+ # returns page uri
+ getter uri : URI
def initialize(uri : URI, response : ::HTTP::Client::Response, body : String, code : Int32)
@uri = uri
diff --git a/src/mechanize/form.cr b/src/mechanize/form.cr
index bbd3e8f..f3a8606 100644
--- a/src/mechanize/form.cr
+++ b/src/mechanize/form.cr
@@ -8,20 +8,31 @@ require "./form/button"
require "./form/select_list"
require "./utils/element_matcher"
+# This class represents the form tag of html.
class Mechanize::Form
include Mechanize::ElementMatcher
getter node : Node | Lexbor::Node
- getter fields : Array(Mechanize::FormContent::Field)
- getter checkboxes : Array(Mechanize::FormContent::CheckBox)
- getter radiobuttons : Array(Mechanize::FormContent::RadioButton)
- getter selectboxes : Array(Mechanize::FormContent::MultiSelectList)
- getter buttons : Array(Mechanize::FormContent::Button)
+ # returns hoge array of `Mechanize::FormContent::Field` in the form.
+ getter fields : Array(FormContent::Field)
+ # returns an array of input tags whose type is checkbox in the form.
+ getter checkboxes : Array(FormContent::CheckBox)
+ # returns an array of input tags whose type is radio in the form.
+ getter radiobuttons : Array(FormContent::RadioButton)
+ # returns an array of input tags whose type is select in the form.
+ getter selectboxes : Array(FormContent::MultiSelectList)
+ # returns an array of button tags and input tag whose type is button,submit,reset,image.
+ getter buttons : Array(FormContent::Button)
+ # returns form's 'enctype' attribute.
getter enctype : String
+ # returns form's 'method' attribute.
getter method : String
+ # returns form's 'name' attribute.
getter name : String
- getter page : Mechanize::Page?
+ # return form's 'action' attribute.
property action : String
+ # returns the page which includes the form.
+ getter page : Mechanize::Page?
def initialize(node : Node | Lexbor::Node, page : Mechanize::Page? = nil)
@enctype = node.fetch("enctype", "application/x-www-form-urlencoded")
@@ -57,7 +68,7 @@ class Mechanize::Form
elements_with "checkbox", "checkboxes"
elements_with "button"
- # Returns all fields of type Textarea
+ # Returns all fields of
def textareas
fields.select { |f| f.class == FormContent::Textarea }.map &.as(FormContent::Textarea)
end
diff --git a/src/mechanize/form/button.cr b/src/mechanize/form/button.cr
index 8a610bf..4a55eda 100644
--- a/src/mechanize/form/button.cr
+++ b/src/mechanize/form/button.cr
@@ -1,3 +1,5 @@
+# This class represents button related html element.
+#