Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[enhance] manpages: added manpage generation program for the Opa comp…

…iler
  • Loading branch information...
commit b79d8ce46fe94594e1feeee40395e02f9a14572b 1 parent b25e4e4
Mathieu Baudet authored
Showing with 52 additions and 13 deletions.
  1. +2 −2 opa/_tags
  2. +27 −0 opa/gen_opa_manpage.ml
  3. +23 −11 opalib/opaEnv.ml
View
4 opa/_tags
@@ -53,10 +53,10 @@
# s3 main
<s3Passes.{ml,mli}>: use_pplib, use_libqmlcompil, use_opalib, use_qmlslicer, use_passlib, use_opapasses, use_qml2ocaml, use_opalang, use_libbsl, use_qmlfakecompiler, use_qmlflatcompiler, use_ocamllang, use_qmlpasses, use_qml2js
-<main.ml>: use_opalib, use_opalang, use_opapasses, use_libqmlcompil, use_qml2ocaml, use_passlib
+<{main,gen_opa_manpage}.ml>: use_opalib, use_opalang, use_opapasses, use_libqmlcompil, use_qml2ocaml, use_passlib
# linking
-<{main,opa_parse,checkopacapi}.{byte,native}>: thread, use_dynlink, use_graph, use_str, use_cryptokit, use_unix, use_nums, use_zip, use_buildinfos, use_libbase, use_ulex, use_libtrx, use_libqmlcompil, use_libbsl, use_opalib, use_opalang, use_opapasses, use_qmlfakecompiler, use_qmlflatcompiler, use_qml2ocaml, use_qmljsimp, use_qml2js, use_opabsl_for_compiler, use_qmlslicer, use_jslang, use_qmlcpsrewriter, use_ocamllang, use_passlib, use_compilerlib, use_pplib, use_qmlpasses, use_opacapi
+<{main,opa_parse,checkopacapi,gen_opa_manpage}.{byte,native}>: thread, use_dynlink, use_graph, use_str, use_cryptokit, use_unix, use_nums, use_zip, use_buildinfos, use_libbase, use_ulex, use_libtrx, use_libqmlcompil, use_libbsl, use_opalib, use_opalang, use_opapasses, use_qmlfakecompiler, use_qmlflatcompiler, use_qml2ocaml, use_qmljsimp, use_qml2js, use_opabsl_for_compiler, use_qmlslicer, use_jslang, use_qmlcpsrewriter, use_ocamllang, use_passlib, use_compilerlib, use_pplib, use_qmlpasses, use_opacapi
<opa_InsertRemote.ml>: with_mlstate_debug
<main_utils.ml>: with_mlstate_debug
View
27 opa/gen_opa_manpage.ml
@@ -0,0 +1,27 @@
+(*
+ Copyright © 2011 MLstate
+
+ This file is part of OPA.
+
+ OPA is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License, version 3, as published by
+ the Free Software Foundation.
+
+ OPA is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
+ more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with OPA. If not, see <http://www.gnu.org/licenses/>.
+*)
+
+(** Print the manpage for the OPA compiler. S3 version. *)
+
+(* Load warnings of opa s3 applications *)
+(* required by some toplevel sideeffects in the modules of OpaEnv *)
+let _ = WarningClass.load_set S3Warnings.warning_set
+
+let _ = OpaEnv.Options.write_manpage stdout
+
+let () = OManager.exit 0
View
34 opalib/opaEnv.ml
@@ -195,6 +195,7 @@ sig
(** Fill a pprocess environment from opa options. *)
val to_ppenv : opa_options -> Pprocess.env -> Pprocess.env
+ val write_manpage : out_channel -> unit
end
=
struct
@@ -411,15 +412,14 @@ struct
(** Options which refers to (and so depends on, ...) options *)
let full_help = ref (fun () -> ())
- let help_menu speclist () =
- let head = Printf.sprintf
- "---- OPA Compiler Help ----
-Syntax is :
+ let command_name = "opa" (* TODO: use buildInfos to know if we are on windows and should add .exe *)
- \"opa.exe [options] source1.opa [source2.opa ...]\"
+ let synopsis = command_name ^ " [options] source1.opa [source2.opa ...]"
-where options are :
-" in
+ let help_menu speclist () =
+ let head =
+ Printf.sprintf "Usage: %s\nwhere options are :\n" synopsis
+ in
Arg.usage speclist head;
if not BuildInfos.is_release
then (
@@ -435,7 +435,7 @@ where options are :
(the function is updated just after the definition of the options list) *)
(* ===== *)
- let parse () =
+ let speclist =
let standard = (* Please preverse the alphabetical order for lisibility *)
OManager.Arg.options @
WarningClass.Arg.options @
@@ -614,16 +614,16 @@ where options are :
"strict", `strict],
" Restrict definition of polymorphic values")
] in
- let speclist =
Arg.sort (
Arg.align (
Arg.add_bash_completion
- ~names:["opa";"opa.exe"]
+ ~name:command_name
~default:(Arg.File "@(opa|cm@(o|a|x|xa|xs)|js|bypass|opack)")
(standard @ (if BuildInfos.is_release then [] else non_release))
)
- ) in
+ )
+ let parse () =
let anon_fun arg =
let ext = File.extension arg in
match ext with
@@ -848,4 +848,16 @@ where options are :
let module JsCC = (val options.js_back_end : Qml2jsOptions.JsBackend) in
Pprocess.add_env "OPA_JS_COMPILER" JsCC.name env
in env
+
+ let write_manpage file =
+ Arg.write_simple_manpage
+ ~cmdname:ArgParser.command_name
+ ~summary:"The Opa compiler"
+ ~section:1
+ ~centerheader:"Opa Manual"
+ ~synopsis:ArgParser.synopsis
+ ~description:"The Opa compiler allows you to compile Opa projects into execute files. Please refer to the online manual on http://opalang.org for a detailed description of the language and its tools.\n"
+ ~options:ArgParser.speclist
+ ~other:[("VERSION", ArgParser.str_version)]
+ file
end
Please sign in to comment.
Something went wrong with that request. Please try again.