homebrew-core/Formula/gi-docgen.rb

94 lines
4.4 KiB
Ruby

class GiDocgen < Formula
include Language::Python::Virtualenv
desc "Documentation tool for GObject-based libraries"
homepage "https://gnome.pages.gitlab.gnome.org/gi-docgen/"
url "https://files.pythonhosted.org/packages/29/72/a319bce143e5d10677bc89b66e750c1511ec005c7a8bb098b415cc68ac68/gi-docgen-2023.1.tar.gz"
sha256 "88adeda9cbf882569479701eada009afa5d94fa29d728653ec388c32035f7fa3"
license any_of: ["Apache-2.0", "GPL-3.0-or-later"]
head "https://gitlab.gnome.org/GNOME/gi-docgen.git", branch: "main"
bottle do
sha256 cellar: :any_skip_relocation, arm64_ventura: "4457956c9dbdd582c2d8a86e23902226cb0f7de110cc28c2036d616677b588f2"
sha256 cellar: :any_skip_relocation, arm64_monterey: "21b1f4b55bc59063bcfcfa500b3c89440b5b1f7f4a93d5168433fd73b2ec8207"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "cf1cdf93e560faf4fbc3dcd6a6d1c00fdf29d9fcba56bba2bec135d58543f22e"
sha256 cellar: :any_skip_relocation, ventura: "d76520359e7bd6d5fa63a0f36354c29676352da054e611966e93fa3c56323597"
sha256 cellar: :any_skip_relocation, monterey: "3e432556d65b23faf4d78216c088dfc1435b6e5c9f7586d2f668b2a2af470743"
sha256 cellar: :any_skip_relocation, big_sur: "77c659d7c8004212417531e491fbb18c40e3dea50740df5c1093f91f68543048"
sha256 cellar: :any_skip_relocation, x86_64_linux: "90ba3994ae191ef527494dc53d54d92c183c18597f4193ec5cbf221e0ead848c"
end
depends_on "pygments"
depends_on "python@3.11"
# Source for latest version is not available on PyPI, so using GitHub tarball instead.
# Issue ref: https://github.com/leohemsted/smartypants.py/issues/8
resource "smartypants" do
url "https://github.com/leohemsted/smartypants.py/archive/refs/tags/v2.0.1.tar.gz"
sha256 "b98191911ff3b4144ef8ad53e776a2d0ad24bd508a905c6ce523597c40022773"
end
resource "Jinja2" do
url "https://files.pythonhosted.org/packages/7a/ff/75c28576a1d900e87eb6335b063fab47a8ef3c8b4d88524c4bf78f670cce/Jinja2-3.1.2.tar.gz"
sha256 "31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"
end
resource "Markdown" do
url "https://files.pythonhosted.org/packages/85/7e/133e943e97a943d2f1d8bae0c5060f8ac50e6691754eb9dbe036b047a9bb/Markdown-3.4.1.tar.gz"
sha256 "3b809086bb6efad416156e00a0da66fe47618a5d6918dd688f53f40c8e4cfeff"
end
resource "MarkupSafe" do
url "https://files.pythonhosted.org/packages/1d/97/2288fe498044284f39ab8950703e88abbac2abbdf65524d576157af70556/MarkupSafe-2.1.1.tar.gz"
sha256 "7f91197cc9e48f989d12e4e6fbc46495c446636dfc81b9ccf50bb0ec74b91d4b"
end
resource "toml" do
url "https://files.pythonhosted.org/packages/be/ba/1f744cdc819428fc6b5084ec34d9b30660f6f9daaf70eead706e3203ec3c/toml-0.10.2.tar.gz"
sha256 "b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"
end
resource "typogrify" do
url "https://files.pythonhosted.org/packages/8a/bf/64959d6187d42472acb846bcf462347c9124952c05bd57e5769d5f28f9a6/typogrify-2.0.7.tar.gz"
sha256 "8be4668cda434163ce229d87ca273a11922cb1614cb359970b7dc96eed13cb38"
end
def install
virtualenv_install_with_resources
end
test do
(testpath/"brew.toml").write <<~EOS
[library]
description = "Homebrew gi-docgen formula test"
authors = "Homebrew"
license = "BSD-2-Clause"
browse_url = "https://github.com/Homebrew/brew"
repository_url = "https://github.com/Homebrew/brew.git"
website_url = "https://brew.sh/"
EOS
(testpath/"brew.gir").write <<~EOS
<?xml version="1.0"?>
<repository version="1.2"
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0">
<namespace name="brew" version="1.0" c:identifier-prefixes="brew" c:symbol-prefixes="brew">
<record name="Formula" c:type="Formula">
<field name="name" writable="1">
<type name="utf8" c:type="char*"/>
</field>
</record>
</namespace>
</repository>
EOS
output = shell_output("#{bin}/gi-docgen generate -C brew.toml brew.gir")
assert_match "Creating namespace index file for brew-1.0", output
assert_predicate testpath/"brew-1.0/index.html", :exist?
assert_predicate testpath/"brew-1.0/struct.Formula.html", :exist?
assert_match %r{Website.*>https://brew.sh/}, (testpath/"brew-1.0/index.html").read
assert_match(/struct.*Formula.*{/, (testpath/"brew-1.0/struct.Formula.html").read)
end
end