Skip to content

Commit aac8f57

Browse files
committed
Improve YARD comments and docs
1 parent 97d970a commit aac8f57

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ With indieweb-endpoints-ruby added to your project's `Gemfile` and installed, yo
4646
require 'indieweb/endpoints'
4747

4848
IndieWeb::Endpoints.get('https://aaronparecki.com')
49-
#=> { authorization_endpoint: "https://aaronparecki.com/auth", micropub: "https://aaronparecki.com/micropub", microsub: "https://aperture.p3k.io/microsub/1", redirect_uri: nil, token_endpoint: "https://aaronparecki.com/auth/token", webmention: "https://webmention.io/aaronpk/webmention" }
49+
#=> { authorization_endpoint: "https://aaronparecki.com/auth", "indieauth-metadata": "https://aaronparecki.com/.well-known/oauth-authorization-server", micropub: "https://aaronparecki.com/micropub", microsub: "https://aperture.p3k.io/microsub/1", redirect_uri: nil, token_endpoint: "https://aaronparecki.com/auth/token", webmention: "https://webmention.io/aaronpk/webmention" }
5050
```
5151

5252
This example will search `https://aaronparecki.com` for valid IndieAuth, Micropub, and Webmention endpoints and return a `Hash` of results. Each key in the returned `Hash` will have a value of either a `String` representing a URL or `nil`. The `redirect_uri` key's value will be either an `Array` or `nil` since a given URL may register multiple callback URLs.

lib/indieweb/endpoints.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ class HttpError < Error; end
1818
class InvalidURIError < Error; end
1919
class SSLError < Error; end
2020

21-
# Discover a URL's IndieAuth, Micropub, Microsub, and Webmention endpoints
21+
# Discover a URL's IndieAuth, Micropub, Microsub, and Webmention endpoints.
2222
#
23+
# Convenience method for {IndieWeb::Endpoints::Client#endpoints}.
24+
#
25+
# @example
2326
# IndieWeb::Endpoints.get('https://aaronparecki.com')
2427
#
25-
# @param url [String] an absolute URL
26-
# @return [Hash{Symbol => String, Array, nil}]
28+
# @param (see IndieWeb::Endpoints::Client#endpoints)
29+
# @return (see IndieWeb::Endpoints::Client#endpoints)
2730
def self.get(url)
2831
Client.new(url).endpoints
2932
end

lib/indieweb/endpoints/client.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ class Client
88
user_agent: 'IndieWeb Endpoint Discovery (https://rubygems.org/gems/indieweb-endpoints)'
99
}.freeze
1010

11-
# Create a new client with a URL to parse for IndieWeb endpoints
11+
# Create a new client with a URL to parse for IndieWeb endpoints.
1212
#
13+
# @example
1314
# client = IndieWeb::Endpoints::Client.new('https://aaronparecki.com')
1415
#
1516
# @param url [String, HTTP::URI, #to_s] an absolute URL
@@ -25,17 +26,17 @@ def inspect
2526
%(#<#{self.class.name}:#{format('%#0x', object_id)} uri: "#{uri}">)
2627
end
2728

28-
# A Hash of the discovered IndieWeb endpoints from the provided URL
29+
# A Hash of the discovered IndieWeb endpoints from the provided URL.
2930
#
3031
# @return [Hash{Symbol => String, Array, nil}]
3132
def endpoints
3233
@endpoints ||= Parser.new(response).results
3334
end
3435

35-
# The HTTP::Response object returned by the provided URL
36+
# The +HTTP::Response+ object returned by the provided URL.
3637
#
3738
# @return [HTTP::Response]
38-
# @raise [IndieWeb::Endpoints::HttpError]
39+
# @raise [IndieWeb::Endpoints::HttpError, IndieWeb::Endpoints::SSLError]
3940
def response
4041
@response ||= HTTP.follow(max_hops: 20)
4142
.headers(HTTP_HEADERS_OPTS)

lib/indieweb/endpoints/response_headers_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def initialize(response)
1010
@uri = response.uri
1111
end
1212

13-
# @param headers [Symbol]
13+
# @param identifier [Symbol]
1414
# @return [Array<String>, nil]
1515
def results_for(identifier)
1616
return unless parsed_headers.key?(identifier)

0 commit comments

Comments
 (0)