homebrew-core/Formula/gi-docgen.rb

99 lines
4.7 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/4d/0d/84d2a72a79ba7874b34680cac5b81019f17d58f2b53d88f341c710f1f3cf/gi-docgen-2022.2.tar.gz"
sha256 "fc56df0c7d4ab9e5ed83f35b7483cb07d0bf91761e4f139eed363d7e42ffe0c0"
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: "28fbf04dad49ead32302a60a9e88eaf90115e808e5df9a35e4f90e68ddfd3bd4"
sha256 cellar: :any_skip_relocation, arm64_monterey: "2bdc1e61f8f6a8cd066c2debbffa52848930ebce700e2481acbcf111ada1df4c"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "cbc18cdca02978e370cd4994c97e02bdb9083a12a3b9cc5e6647464426d734c2"
sha256 cellar: :any_skip_relocation, ventura: "3f0d1c663afe3b52787c7b0ca7ecca1f92f2d9e7300377c12dd6a11177d714a5"
sha256 cellar: :any_skip_relocation, monterey: "194f50b12ce008e6c0533b3e658e99e16211edca7eabfc8599eabd742e31eecf"
sha256 cellar: :any_skip_relocation, big_sur: "77f7543d7583217d4092f25743dd70c59f42c75ae3da32f4142c28b2fc33bba5"
sha256 cellar: :any_skip_relocation, catalina: "78d73e32cfc350ea7f501074753dee254854c0c9127955db6377777a9669cd74"
sha256 cellar: :any_skip_relocation, x86_64_linux: "edd16dfe78250cbdc8ce461aa9a925c2121754539f494ad978bc4c21be77a275"
end
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 "Pygments" do
url "https://files.pythonhosted.org/packages/e0/ef/5905cd3642f2337d44143529c941cc3a02e5af16f0f65f81cbef7af452bb/Pygments-2.13.0.tar.gz"
sha256 "56a8508ae95f98e2b9bdf93a6be5ae3f7d8af858b43e02c5a2ff083726be40c1"
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