Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for Hurl 6.0.0 #99

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 57 additions & 30 deletions sites/generate/build_jekyll_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@
Examples:
$ python3 sites/generate/build_jekyll_md.py
"""

import argparse
import re
import gzip
import shutil
import sys
import tomllib
from pathlib import Path
from typing import Optional

Expand Down Expand Up @@ -204,7 +208,15 @@ def convert(self):
self.file_dst.write_text(md)


def build():
def build(standalone: bool):
"""Build a jekyll project for documentation from original repo"""
# Identify version
with open("../hurl/packages/hurl/Cargo.toml", "rb") as f:
data = tomllib.load(f)
version = data["package"]["version"]
version = version.replace("-SNAPSHOT", "")
sys.stderr.write(f"version:{version}\n")

docs = [
(
Path("../hurl/docs/home.md"),
Expand Down Expand Up @@ -391,19 +403,23 @@ def build():
FrontMatter(layout="doc", section="Resources"),
False,
),
(
Path("../hurl/docs/standalone/hurl-5.0.1.md"),
Path("sites/hurl.dev/_docs/standalone/hurl-5.0.1.md"),
FrontMatter(
layout="standalone",
section="Standalone",
title="Hurl 5.0.1",
indexed=False,
),
False,
),
]

if standalone:
docs.append(
(
Path(f"../hurl/docs/standalone/hurl-{version}.md"),
Path(f"sites/hurl.dev/_docs/standalone/hurl-{version}.md"),
FrontMatter(
layout="standalone",
section="Standalone",
title=f"Hurl {version}",
indexed=False,
),
False,
),
)

for src, dst, front_matter, force_list_numbering in docs:
task = ConvertTask(
file_src=src,
Expand Down Expand Up @@ -453,21 +469,22 @@ def build():
"../hurl/docs/assets/img/quiz-light.png",
"sites/hurl.dev/assets/img/quiz-light.png",
)
compress(src=Path("../hurl/docs/standalone/hurl-5.0.1.md"))
shutil.move(
"../hurl/docs/standalone/hurl-5.0.1.md.gz",
"sites/hurl.dev/assets/docs/hurl-5.0.1.md.gz",
)
compress(src=Path("../hurl/docs/standalone/hurl-5.0.1.html"))
shutil.move(
"../hurl/docs/standalone/hurl-5.0.1.html.gz",
"sites/hurl.dev/assets/docs/hurl-5.0.1.html.gz",
)
compress(src=Path("../hurl/docs/standalone/hurl-5.0.1.pdf"))
shutil.move(
"../hurl/docs/standalone/hurl-5.0.1.pdf.gz",
"sites/hurl.dev/assets/docs/hurl-5.0.1.pdf.gz",
)
if standalone:
compress(src=Path(f"../hurl/docs/standalone/hurl-{version}.md"))
shutil.move(
f"../hurl/docs/standalone/hurl-{version}.md.gz",
f"sites/hurl.dev/assets/docs/hurl-{version}.md.gz",
)
compress(src=Path(f"../hurl/docs/standalone/hurl-{version}.html"))
shutil.move(
f"../hurl/docs/standalone/hurl-{version}.html.gz",
f"sites/hurl.dev/assets/docs/hurl-{version}.html.gz",
)
compress(src=Path(f"../hurl/docs/standalone/hurl-{version}.pdf"))
shutil.move(
f"../hurl/docs/standalone/hurl-{version}.pdf.gz",
f"sites/hurl.dev/assets/docs/hurl-{version}.pdf.gz",
)


def compress(src: Path):
Expand All @@ -476,9 +493,19 @@ def compress(src: Path):
shutil.copyfileobj(f_in, f_out)


def main():
build()
def main(standalone: bool):
build(standalone=standalone)


if __name__ == "__main__":
main()
parser = argparse.ArgumentParser(
description="Build jekyll source from https://github.com/Orange-OpenSource/hurl"
)
parser.add_argument(
"--standalone",
action="store_true",
default=False,
help="Generate standalone docs",
)
args = parser.parse_args()
main(standalone=args.standalone)
5 changes: 4 additions & 1 deletion sites/hurl.dev/_data/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
- title: Templating a JSON Body
- title: Templating a XML Body
- title: Using GraphQL Query
- title: Using Dynamic Datas
- title: Testing Response
items:
- title: Testing Response Headers
Expand Down Expand Up @@ -161,6 +162,7 @@
- title: Method
- title: URL
- title: Headers
- title: Options
- title: Query parameters
- title: Form parameters
- title: Multipart Form Data
Expand All @@ -176,7 +178,6 @@
- title: Base64 body
- title: Hex body
- title: File body
- title: Options
- title: Response
path: /docs/response.html
items:
Expand Down Expand Up @@ -266,6 +267,7 @@
path: /docs/templates.html
items:
- title: Variables
- title: Functions
- title: Types
- title: Injecting Variables
items:
Expand Down Expand Up @@ -321,6 +323,7 @@
- title: Get Response Body
- title: Interactive Mode
- title: Include Headers Like curl
- title: Export curl Commands
- title: Using a Proxy
- title: Captures
path: /docs/tutorial/captures.html
Expand Down
8 changes: 4 additions & 4 deletions sites/hurl.dev/_docs/asserting-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ after this delimiter, you'll find the implicit asserts, then an `[Asserts]` sect


```hurl
GET https://api/example.org/cats
GET https://example.org/api/cats
HTTP 200
Content-Type: application/json; charset=utf-8 # Implicit assert on Content-Type Header
[Asserts] # Explicit asserts section
Expand Down Expand Up @@ -567,7 +567,7 @@ Alternatively, `matches` predicate support [JavaScript-like Regular expression s
the readability:

```hurl
GET https://sample.org/hello
GET https://example.org/hello
HTTP 200
[Asserts]

Expand All @@ -585,7 +585,7 @@ jsonpath "$.name" matches /Hello [a-zA-Z]+!/
Check that the HTTP received body, decoded as text, matches a regex pattern.

```hurl
GET https://sample.org/hello
GET https://example.org/hello
HTTP 200
[Asserts]
regex "^(\\d{4}-\\d{2}-\\d{2})$" == "2018-12-31"
Expand Down Expand Up @@ -639,7 +639,7 @@ variable "pets" count == 200
Check the total duration (sending plus receiving time) of the HTTP transaction.

```hurl
GET https://sample.org/helloworld
GET https://example.org/helloworld
HTTP 200
[Asserts]
duration < 1000 # Check that response time is less than one second
Expand Down
2 changes: 1 addition & 1 deletion sites/hurl.dev/_docs/filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Decode bytes to string using encoding.
```hurl
# The 'Content-Type' HTTP response header does not precise the charset 'gb2312'
# so body must be decoded explicitly by Hurl before processing any text based assert
GET https://exapple.org/hello_china
GET https://example.org/hello_china
HTTP 200
[Asserts]
header "Content-Type" == "text/html"
Expand Down
Loading
Loading