Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 42 lines (35 sloc) 1.483 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
-- Implicit CAD. Copyright (C) 2011, Christopher Olah (chris@colah.ca)
-- Released under the GNU GPL, see LICENSE

{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, FlexibleContexts, TypeSynonymInstances, UndecidableInstances, ScopedTypeVariables #-}

import Graphics.Implicit.ExtOpenScad.Primitives (primitives)
import Graphics.Implicit.ExtOpenScad.Util.ArgParser

import Control.Monad

isExample (ExampleDoc _ ) = True
isExample _ = False

isArgument (ArgumentDoc _ _ _) = True
isArgument _ = False

main = do
let names = map fst primitives
docs <- sequence $ map (getArgParserDocs.($ []).snd) primitives

forM_ (zip names docs) $ \(moduleName, moduleDocList) -> do
let
examples = filter isExample moduleDocList
arguments = filter isArgument moduleDocList
putStrLn moduleName
if not $ null examples then putStrLn " examples:" else return ()
forM_ examples $ \(ExampleDoc example) ->
putStrLn $ " " ++ example
putStrLn " arguments:"
forM_ arguments $ \(ArgumentDoc name posfallback description) ->
case (posfallback, description) of
(Nothing, "") -> do
putStrLn $ " " ++ name
(Just fallback, "") -> do
putStrLn $ " " ++ name ++ " = " ++ fallback
(Nothing, _) -> do
putStrLn $ " " ++ name
putStrLn $ " " ++ description
(Just fallback, _) -> do
putStrLn $ " " ++ name ++ " = " ++ fallback
putStrLn $ " " ++ description
putStrLn ""
Something went wrong with that request. Please try again.