context.dev 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -75,6 +75,10 @@ module ContextDev
75
75
  LINK = :link
76
76
  SOURCE = :source
77
77
  VIDEO = :video
78
+ CSS = :css
79
+ OBJECT = :object
80
+ META = :meta
81
+ BACKGROUND = :background
78
82
 
79
83
  # @!method self.values
80
84
  # @return [Array<Symbol>]
@@ -32,7 +32,14 @@ module ContextDev
32
32
  # @return [Boolean, nil]
33
33
  optional :shorten_base64_images, ContextDev::Internal::Type::Boolean
34
34
 
35
- # @!method initialize(url:, include_images: nil, include_links: nil, shorten_base64_images: nil, request_options: {})
35
+ # @!attribute use_main_content_only
36
+ # Extract only the main content of the page, excluding headers, footers, sidebars,
37
+ # and navigation
38
+ #
39
+ # @return [Boolean, nil]
40
+ optional :use_main_content_only, ContextDev::Internal::Type::Boolean
41
+
42
+ # @!method initialize(url:, include_images: nil, include_links: nil, shorten_base64_images: nil, use_main_content_only: nil, request_options: {})
36
43
  # Some parameter documentations has been truncated, see
37
44
  # {ContextDev::Models::WebWebScrapeMdParams} for more details.
38
45
  #
@@ -44,6 +51,8 @@ module ContextDev
44
51
  #
45
52
  # @param shorten_base64_images [Boolean] Shorten base64-encoded image data in the Markdown output
46
53
  #
54
+ # @param use_main_content_only [Boolean] Extract only the main content of the page, excluding headers, footers, sidebars,
55
+ #
47
56
  # @param request_options [ContextDev::RequestOptions, Hash{Symbol=>Object}]
48
57
  end
49
58
  end
@@ -40,14 +40,12 @@ module ContextDev
40
40
  # Either 'domain' or 'directUrl' must be provided as a query parameter, but not
41
41
  # both.
42
42
  #
43
- # @overload extract_styleguide(direct_url: nil, domain: nil, prioritize: nil, timeout_ms: nil, request_options: {})
43
+ # @overload extract_styleguide(direct_url: nil, domain: nil, timeout_ms: nil, request_options: {})
44
44
  #
45
45
  # @param direct_url [String] A specific URL to fetch the styleguide from directly, bypassing domain resolutio
46
46
  #
47
47
  # @param domain [String] Domain name to extract styleguide from (e.g., 'example.com', 'google.com'). The
48
48
  #
49
- # @param prioritize [Symbol, ContextDev::Models::StyleExtractStyleguideParams::Prioritize] Optional parameter to prioritize screenshot capture for styleguide extraction. I
50
- #
51
49
  # @param timeout_ms [Integer] Optional timeout in milliseconds for the request. If the request takes longer th
52
50
  #
53
51
  # @param request_options [ContextDev::RequestOptions, Hash{Symbol=>Object}, nil]
@@ -92,7 +92,7 @@ module ContextDev
92
92
  # Scrapes the given URL, converts the HTML content to Markdown, and returns the
93
93
  # result.
94
94
  #
95
- # @overload web_scrape_md(url:, include_images: nil, include_links: nil, shorten_base64_images: nil, request_options: {})
95
+ # @overload web_scrape_md(url:, include_images: nil, include_links: nil, shorten_base64_images: nil, use_main_content_only: nil, request_options: {})
96
96
  #
97
97
  # @param url [String] Full URL to scrape and convert to markdown (must include http:// or https:// pro
98
98
  #
@@ -102,6 +102,8 @@ module ContextDev
102
102
  #
103
103
  # @param shorten_base64_images [Boolean] Shorten base64-encoded image data in the Markdown output
104
104
  #
105
+ # @param use_main_content_only [Boolean] Extract only the main content of the page, excluding headers, footers, sidebars,
106
+ #
105
107
  # @param request_options [ContextDev::RequestOptions, Hash{Symbol=>Object}, nil]
106
108
  #
107
109
  # @return [ContextDev::Models::WebWebScrapeMdResponse]
@@ -116,7 +118,8 @@ module ContextDev
116
118
  query: query.transform_keys(
117
119
  include_images: "includeImages",
118
120
  include_links: "includeLinks",
119
- shorten_base64_images: "shortenBase64Images"
121
+ shorten_base64_images: "shortenBase64Images",
122
+ use_main_content_only: "useMainContentOnly"
120
123
  ),
121
124
  model: ContextDev::Models::WebWebScrapeMdResponse,
122
125
  options: options
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ContextDev
4
- VERSION = "1.0.0"
4
+ VERSION = "1.2.0"
5
5
  end
@@ -148,12 +148,20 @@ module ContextDev
148
148
  end
149
149
  end
150
150
 
151
+ # https://www.rfc-editor.org/rfc/rfc3986.html#section-3.3
152
+ RFC_3986_NOT_PCHARS = T.let(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/, Regexp)
153
+
151
154
  class << self
152
155
  # @api private
153
156
  sig { params(uri: URI::Generic).returns(String) }
154
157
  def uri_origin(uri)
155
158
  end
156
159
 
160
+ # @api private
161
+ sig { params(path: T.any(String, Integer)).returns(String) }
162
+ def encode_path(path)
163
+ end
164
+
157
165
  # @api private
158
166
  sig { params(path: T.any(String, T::Array[String])).returns(String) }
159
167
  def interpolate_path(path)
@@ -30,27 +30,6 @@ module ContextDev
30
30
  sig { params(domain: String).void }
31
31
  attr_writer :domain
32
32
 
33
- # Optional parameter to prioritize screenshot capture for styleguide extraction.
34
- # If 'speed', optimizes for faster capture with basic quality. If 'quality',
35
- # optimizes for higher quality with longer wait times. Defaults to 'quality' if
36
- # not provided.
37
- sig do
38
- returns(
39
- T.nilable(
40
- ContextDev::StyleExtractStyleguideParams::Prioritize::OrSymbol
41
- )
42
- )
43
- end
44
- attr_reader :prioritize
45
-
46
- sig do
47
- params(
48
- prioritize:
49
- ContextDev::StyleExtractStyleguideParams::Prioritize::OrSymbol
50
- ).void
51
- end
52
- attr_writer :prioritize
53
-
54
33
  # Optional timeout in milliseconds for the request. If the request takes longer
55
34
  # than this value, it will be aborted with a 408 status code. Maximum allowed
56
35
  # value is 300000ms (5 minutes).
@@ -64,8 +43,6 @@ module ContextDev
64
43
  params(
65
44
  direct_url: String,
66
45
  domain: String,
67
- prioritize:
68
- ContextDev::StyleExtractStyleguideParams::Prioritize::OrSymbol,
69
46
  timeout_ms: Integer,
70
47
  request_options: ContextDev::RequestOptions::OrHash
71
48
  ).returns(T.attached_class)
@@ -77,11 +54,6 @@ module ContextDev
77
54
  # Domain name to extract styleguide from (e.g., 'example.com', 'google.com'). The
78
55
  # domain will be automatically normalized and validated.
79
56
  domain: nil,
80
- # Optional parameter to prioritize screenshot capture for styleguide extraction.
81
- # If 'speed', optimizes for faster capture with basic quality. If 'quality',
82
- # optimizes for higher quality with longer wait times. Defaults to 'quality' if
83
- # not provided.
84
- prioritize: nil,
85
57
  # Optional timeout in milliseconds for the request. If the request takes longer
86
58
  # than this value, it will be aborted with a 408 status code. Maximum allowed
87
59
  # value is 300000ms (5 minutes).
@@ -95,8 +67,6 @@ module ContextDev
95
67
  {
96
68
  direct_url: String,
97
69
  domain: String,
98
- prioritize:
99
- ContextDev::StyleExtractStyleguideParams::Prioritize::OrSymbol,
100
70
  timeout_ms: Integer,
101
71
  request_options: ContextDev::RequestOptions
102
72
  }
@@ -104,41 +74,6 @@ module ContextDev
104
74
  end
105
75
  def to_hash
106
76
  end
107
-
108
- # Optional parameter to prioritize screenshot capture for styleguide extraction.
109
- # If 'speed', optimizes for faster capture with basic quality. If 'quality',
110
- # optimizes for higher quality with longer wait times. Defaults to 'quality' if
111
- # not provided.
112
- module Prioritize
113
- extend ContextDev::Internal::Type::Enum
114
-
115
- TaggedSymbol =
116
- T.type_alias do
117
- T.all(Symbol, ContextDev::StyleExtractStyleguideParams::Prioritize)
118
- end
119
- OrSymbol = T.type_alias { T.any(Symbol, String) }
120
-
121
- SPEED =
122
- T.let(
123
- :speed,
124
- ContextDev::StyleExtractStyleguideParams::Prioritize::TaggedSymbol
125
- )
126
- QUALITY =
127
- T.let(
128
- :quality,
129
- ContextDev::StyleExtractStyleguideParams::Prioritize::TaggedSymbol
130
- )
131
-
132
- sig do
133
- override.returns(
134
- T::Array[
135
- ContextDev::StyleExtractStyleguideParams::Prioritize::TaggedSymbol
136
- ]
137
- )
138
- end
139
- def self.values
140
- end
141
- end
142
77
  end
143
78
  end
144
79
  end