Skip to content

Commit 62187d3

Browse files
committed
generate markdown from registry
1 parent 69adfa1 commit 62187d3

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed

docs/make_docs.jl

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using FileIO, Compat
2+
import FileIO: LOAD, SAVE, OSX, OS
3+
const fs = open(Pkg.dir("FileIO", "docs", "registry.md"), "w")
4+
extension2string(x) = join(map(string, x), ", ")
5+
extension2string(x::AbstractString) = x
6+
os2string(x::Vector) = isempty(x) ? "ALL" : join(map(os2string, x), ", ")
7+
os2string{O <: OS}(os::Type{O}) = string(O.name.name)
8+
magic2string(x::Function) = "has detection function"
9+
magic2string(x::Tuple) = isempty(x) ? "only extension": string(x)
10+
magic2string(x) = string(x)
11+
function loadsave2string(load_save_libraries)
12+
io = IOBuffer()
13+
loader_str, saver_str = " ", " "
14+
for predicates in load_save_libraries
15+
library = shift!(predicates)
16+
17+
os, loadsave = FileIO.split_predicates(predicates)
18+
if isempty(loadsave)
19+
print(io, "loads and saves on all platforms with ", library)
20+
elseif (LOAD in loadsave)
21+
print(io, "loads with ", library, " on: ", os2string(os), " ")
22+
elseif (SAVE in loadsave)
23+
print(io, "loads with ", library, " on: ", os2string(os), " ")
24+
end
25+
end
26+
takebuf_string(io)
27+
end
28+
function add_format{Sym}(::Type{DataFormat{Sym}}, magic, extension, io_libs...)
29+
println(fs, "| $(Sym) | $(extension2string(extension)) | $(loadsave2string(io_libs)) | $(magic2string(magic)) |")
30+
end
31+
32+
33+
function add_format{sym}(fmt::Type{DataFormat{sym}}, magic::@compat(Union{Tuple,AbstractVector,ByteString}), extension)
34+
println(sym)
35+
end
36+
37+
# for multiple magic bytes
38+
function add_format{sym, T <: Vector{UInt8}, N}(fmt::Type{DataFormat{sym}}, magics::NTuple{N, T}, extension)
39+
println(sym)
40+
end
41+
42+
# For when "magic" is supplied as a function (see the HDF5 example in
43+
# registry.jl)
44+
function add_format{sym}(fmt::Type{DataFormat{sym}}, magic, extension)
45+
println(sym)
46+
end
47+
48+
49+
println(fs, """
50+
| Format Name | extensions | IO library | detection or magic number |
51+
| ----------- | ---------- | ---------- | ---------- |""")
52+
include(Pkg.dir("FileIO", "src", "registry.jl"))
53+
54+
close(fs)

docs/registry.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
| Format Name | extensions | IO library | detection or magic number |
2+
| ----------- | ---------- | ---------- | ---------- |
3+
| JLD | .jld | loads and saves on all platforms with JLD | Julia data file (HDF5) |
4+
| PBMBinary | .pbm | loads and saves on all platforms with ImageMagick | UInt8[0x50,0x34] |
5+
| PGMBinary | .pgm | loads and saves on all platforms with Netpbm | UInt8[0x50,0x35] |
6+
| PPMBinary | .ppm | loads and saves on all platforms with Netpbm | UInt8[0x50,0x36] |
7+
| PBMText | .pbm | loads with ImageMagick on: ALL | UInt8[0x50,0x31] |
8+
| PGMText | .pgm | loads with ImageMagick on: ALL | UInt8[0x50,0x32] |
9+
| PPMText | .ppm | loads with ImageMagick on: ALL | UInt8[0x50,0x33] |
10+
| NRRD | .nrrd, .nhdr | loads and saves on all platforms with NRRD | NRRD |
11+
| AndorSIF | .sif | loads with AndorSIF on: ALL | Andor Technology Multi-Channel File |
12+
| CRW | .crw | loads and saves on all platforms with ImageMagick | UInt8[0x49,0x49,0x1a,0x00,0x00,0x00,0x48,0x45] |
13+
| CUR | .cur | loads and saves on all platforms with ImageMagick | UInt8[0x00,0x00,0x02,0x00] |
14+
| DCX | .dcx | loads and saves on all platforms with ImageMagick | UInt8[0xb1,0x68,0xde,0x3a] |
15+
| DOT | .dot | loads and saves on all platforms with ImageMagick | UInt8[0xd0,0xcf,0x11,0xe0,0xa1,0xb1,0x1a,0xe1] |
16+
| EPS | .eps | loads and saves on all platforms with ImageMagick | UInt8[0x25,0x21,0x50,0x53,0x2d,0x41,0x64,0x6f] |
17+
| HDR | .hdr | loads and saves on all platforms with ImageMagick | UInt8[0x23,0x3f,0x52,0x41,0x44,0x49,0x41,0x4e] |
18+
| ICO | .ico | loads and saves on all platforms with ImageMagick | UInt8[0x00,0x00,0x01,0x00] |
19+
| INFO | .info | loads and saves on all platforms with ImageMagick | UInt8[0x7a,0x62,0x65,0x78] |
20+
| JP2 | .jp2 | loads and saves on all platforms with ImageMagick | UInt8[0x00,0x00,0x00,0x0c,0x6a,0x50,0x20,0x20] |
21+
| PCX | .pcx | loads and saves on all platforms with ImageMagick | UInt8[0x0a,0x05,0x01,0x01] |
22+
| PDB | .pdb | loads and saves on all platforms with ImageMagick | UInt8[0x73,0x7a,0x65,0x7a] |
23+
| PDF | .pdf | loads and saves on all platforms with ImageMagick | UInt8[0x25,0x50,0x44,0x46] |
24+
| PGM | .pgm | loads and saves on all platforms with ImageMagick | UInt8[0x50,0x35,0x0a] |
25+
| PSD | .psd | loads and saves on all platforms with ImageMagick | UInt8[0x38,0x42,0x50,0x53] |
26+
| RGB | .rgb | loads and saves on all platforms with ImageMagick | UInt8[0x01,0xda,0x01,0x01,0x00,0x03] |
27+
| WMF | .wmf | loads and saves on all platforms with ImageMagick | UInt8[0xd7,0xcd,0xc6,0x9a] |
28+
| WPG | .wpg | loads and saves on all platforms with ImageMagick | UInt8[0xff,0x57,0x50,0x43] |
29+
| Imagine | .imagine | loads and saves on all platforms with ImagineFormat | IMAGINE |
30+
| TGA | .tga | loads with QuartzImageIO on: OSX loads and saves on all platforms with ImageMagick | only extension |
31+
| GIF | .gif | loads with QuartzImageIO on: OSX loads and saves on all platforms with ImageMagick | UInt8[0x47,0x49,0x46,0x38] |
32+
| PNG | .png | loads with QuartzImageIO on: OSX loads and saves on all platforms with ImageMagick | UInt8[0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a] |
33+
| TIFF | .tiff, .tif | loads with QuartzImageIO on: OSX loads and saves on all platforms with ImageMagick | (UInt8[0x4d,0x4d,0x00,0x2a],UInt8[0x4d,0x4d,0x00,0x2b],UInt8[0x49,0x49,0x2a,0x00]) |
34+
| JPEG | .jpeg, .jpg, .JPG | loads with QuartzImageIO on: OSX loads and saves on all platforms with ImageMagick | UInt8[0xff,0xd8,0xff] |
35+
| BMP | .bmp | loads with QuartzImageIO on: OSX loads and saves on all platforms with ImageMagick | UInt8[0x42,0x4d] |
36+
| GLSLShader | .frag, .vert, .geom, .comp | loads and saves on all platforms with GLAbstraction | only extension |
37+
| OBJ | .obj | loads and saves on all platforms with MeshIO | only extension |
38+
| PLY_ASCII | .ply | loads and saves on all platforms with MeshIO | ply
39+
format ascii 1.0 |
40+
| PLY_BINARY | .ply | loads and saves on all platforms with MeshIO | ply
41+
format binary_little_endian 1.0 |
42+
| 2DM | .2dm | loads and saves on all platforms with MeshIO | MESH2D |
43+
| OFF | .off | loads and saves on all platforms with MeshIO | OFF |
44+
| AVI | .avi | loads and saves on all platforms with ImageMagick | has detection function |
45+
| HDF5 | .h5, .hdf5 | loads and saves on all platforms with HDF5 | has detection function |
46+
| STL_ASCII | .stl, .STL | loads and saves on all platforms with MeshIO | has detection function |
47+
| STL_BINARY | .stl, .STL | loads and saves on all platforms with MeshIO | has detection function |

0 commit comments

Comments
 (0)