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

RFC: Create a listing of all packages #1935

Merged
merged 2 commits into from
Jan 8, 2013
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
7 changes: 6 additions & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
JULIA = ../julia

# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
Expand All @@ -19,7 +20,7 @@ JQUERYURL = http://code.jquery.com/jquery-latest.js
WGET = $(abspath ../deps)/jldownload

.PHONY: help clean clean-jquery cleanall get-jquery html dirhtml singlehtml pickle json htmlhelp qthelp devhelp \
epub latex latexpdf text man changes linkcheck doctest gettext
epub latex latexpdf text man changes linkcheck doctest gettext listpkg

help:
@echo "Please use \`make <target>' where <target> is one of"
Expand All @@ -43,6 +44,7 @@ help:
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
@echo " listpkg to recreate the list of available packages"

clean:
-rm -rf $(BUILDDIR)/*
Expand Down Expand Up @@ -172,3 +174,6 @@ doctest:
helpdb.jl: stdlib/*.rst sphinx/jlhelp.py sphinx/julia.py
$(SPHINXBUILD) -b jlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/jlhelp
mv $(BUILDDIR)/jlhelp/jlhelp.jl helpdb.jl

listpkg:
$(JULIA) listpkg.jl
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

manual/index
stdlib/index
packages/packagelist

Indices and tables
==================
Expand Down
86 changes: 86 additions & 0 deletions doc/listpkg.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
require("pkg")
try
require("JSON")
catch
Pkg.add("JSON")
require("JSON")
end

function gen_listpkg()
local gh_auth
try
gh_auth = ENV["GH_AUTH"]
catch e
error ("Please provide a Github OAuth Token as environment variable GH_AUTH")
end
Pkg.update()
io=open("packages/packagelist.rst","w+");
print(io, "********************\n Available Packages \n********************\n\n")
cd(julia_pkgdir()) do
for pkg in Metadata.each_package()
print(" Processing $(pkg)\n")
url = (Metadata.pkg_url(pkg))
maxv = Metadata.versions([pkg])[end]
url_reg = r"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?"
gh_path_reg_git=r"^/(.*)?/(.*)?.git$"
gh_path_reg_http=r"^/(.*)?/(.*)?$"
m=match(url_reg, url)
host=m.captures[4]
path=m.captures[5]
scheme=m.captures[2]
fullname = "Unkown"
avatar = "Not on Github"
desc = "Not provided"
homepage = nothing
html_url = url
user_url = url

if ismatch(r"github\.com", host)
m2 = match(gh_path_reg_git, path)
user=m2.captures[1]
repo=m2.captures[2]
gh_repo_url = "https://api.github.com/repos/$(user)/$(repo)?access_token=$(gh_auth)"
gh_user_url = "https://api.github.com/users/$(user)?access_token=$(gh_auth)"
#print("processing $gh_repo_url")
gh_repo=JSON.parse(readall(download_file(gh_repo_url)))
#print("processing $gh_user_url")
gh_user=JSON.parse(readall(download_file(gh_user_url)))
fullname = get(gh_user, "name", user)
avatar = gh_user["avatar_url"]
user_url = gh_user["html_url"]
desc = get(gh_repo, "description", "No description provided")
homepage = get(gh_repo, "homepage", nothing)
html_url = gh_repo["html_url"]
end
print(io, "`$(pkg) <$(html_url)>`_\n");
print(io, "_"^(length("`$(pkg) <$(html_url)>`_")) * "\n\n")
print(io, " .. image:: $(avatar)\n :height: 80px\n :width: 80px\n :align: right\n :alt: $(fullname)\n")
print(io, " Current Version: ``$(maxv.version)``\n\n");
print(io, " $(desc) \n\n")
print(io, " Maintainer: `$(fullname) <$user_url>`_\n\n")

if homepage != nothing && length(chomp(homepage)) > 0
print(io, " More Info: `<$(homepage)>`_ \n\n")
end
print(io, " Dependencies::\n\n" )
ver_dir = "METADATA/$pkg/versions/$(maxv.version)/requires"
any_ver = "Any Version"
if isfile(ver_dir)
vset = Metadata.parse_requires(ver_dir)
if length(vset) > 0
for deps in vset
print(io, " $(deps.package)"); print(io, " "^(15-length(deps.package))); print(io, "$(length(deps.versions)>0 ? deps.versions : any_ver)\n")
end
else
print(io, " None\n")
end
else
print(io, " None\n")
end
print(io, "\n")
end #for
end #cd
close(io)
end #function

gen_listpkg()
Loading