From 1074fc8ae8f7135b11d4e867949a2e86a109b6b3 Mon Sep 17 00:00:00 2001 From: schwarze Date: Wed, 25 Dec 2013 22:00:34 +0000 Subject: [PATCH] Implement .Fo/.Fa/.Fc indentation and break handling for -Tman. --- regress/usr.bin/mandoc/mdoc/Bk/break.in | 6 +++- .../usr.bin/mandoc/mdoc/Bk/break.out_ascii | 2 ++ regress/usr.bin/mandoc/mdoc/Bk/synopsis.in | 7 ++++- .../usr.bin/mandoc/mdoc/Bk/synopsis.out_ascii | 5 ++++ regress/usr.bin/mandoc/mdoc/Fo/break.in | 29 ++++++++++++++++++- .../usr.bin/mandoc/mdoc/Fo/break.out_ascii | 23 +++++++++++++++ usr.bin/mandoc/mdoc_man.c | 13 ++++++--- 7 files changed, 78 insertions(+), 7 deletions(-) diff --git a/regress/usr.bin/mandoc/mdoc/Bk/break.in b/regress/usr.bin/mandoc/mdoc/Bk/break.in index ce3d5a9bbcc..f690c77bdf8 100644 --- a/regress/usr.bin/mandoc/mdoc/Bk/break.in +++ b/regress/usr.bin/mandoc/mdoc/Bk/break.in @@ -1,4 +1,4 @@ -.Dd $Mdocdate: May 29 2013 $ +.Dd $Mdocdate: December 25 2013 $ .Dt BK-BREAK 1 .Os OpenBSD .Sh NAME @@ -46,4 +46,8 @@ with the text following it: .Pp .Bk -words .Fn xxxxxxxxxxxxxxxxxxxx "xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx" xxxxxxxxxxxxxxxxxxxx +.Pp +.Fo xxxxxxxxxxxxxxxxxxxx +.Fa "xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx" xxxxxxxxxxxxxxxxxxxx +.Fc .Ek diff --git a/regress/usr.bin/mandoc/mdoc/Bk/break.out_ascii b/regress/usr.bin/mandoc/mdoc/Bk/break.out_ascii index a0b5145204d..0c10c301880 100644 --- a/regress/usr.bin/mandoc/mdoc/Bk/break.out_ascii +++ b/regress/usr.bin/mandoc/mdoc/Bk/break.out_ascii @@ -25,4 +25,6 @@ DDEESSCCRRIIPPTTIIOONN xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x _x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x, _x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x) + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x _x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x, _x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x) + OpenBSD May 29, 2013 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Bk/synopsis.in b/regress/usr.bin/mandoc/mdoc/Bk/synopsis.in index 62c3e0370f9..1f7f7206a41 100644 --- a/regress/usr.bin/mandoc/mdoc/Bk/synopsis.in +++ b/regress/usr.bin/mandoc/mdoc/Bk/synopsis.in @@ -1,4 +1,4 @@ -.Dd $Mdocdate: December 24 2013 $ +.Dd $Mdocdate: December 25 2013 $ .Dt BK-SYNOPSIS 1 .Os OpenBSD .Sh NAME @@ -9,6 +9,11 @@ In the synopsis, almost all macros do not show .No the word keep effect they would get in a \&Bk block. .Pp .Fn xxxxxxxxxxxxxxxxxxxx "xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx" xxxxxxxxxxxxxxxxxxxx +.Fo xxxxxxxxxxxxxxxxxxxx +.Fa "xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx" xxxxxxxxxxxxxxxxxxxx +.Fc +.Pp +Only \&Nm, used as a block macro, does: .Pp .Nm ksh .Op Fl +abCefhiklmnpruvXx diff --git a/regress/usr.bin/mandoc/mdoc/Bk/synopsis.out_ascii b/regress/usr.bin/mandoc/mdoc/Bk/synopsis.out_ascii index 01e839f4d30..5372a02b5ae 100644 --- a/regress/usr.bin/mandoc/mdoc/Bk/synopsis.out_ascii +++ b/regress/usr.bin/mandoc/mdoc/Bk/synopsis.out_ascii @@ -10,6 +10,11 @@ SSYYNNOOPPSSIISS xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x _x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x, _x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x); + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x _x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x, + _x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x); + + Only Nm, used as a block macro, does: + kksshh [--++aabbCCeeffhhiikkllmmnnpprruuvvXXxx] [--++oo _o_p_t_i_o_n] [--cc _s_t_r_i_n_g | --ss | _f_i_l_e [_a_r_g_u_m_e_n_t _._._.]] kksshh [--++aabbCCeeffhhiikkllmmnnpprruuvvXXxx] [--++oo _o_p_t_i_o_n] diff --git a/regress/usr.bin/mandoc/mdoc/Fo/break.in b/regress/usr.bin/mandoc/mdoc/Fo/break.in index 2a5d1dcd699..3571cbd593d 100644 --- a/regress/usr.bin/mandoc/mdoc/Fo/break.in +++ b/regress/usr.bin/mandoc/mdoc/Fo/break.in @@ -1,11 +1,38 @@ -.Dd December 25, 2013 +.Dd $Mdocdate: December 25 2013 $ .Dt FO-BREAK 1 .Os OpenBSD .Sh NAME .Nm Fo-break .Nd line breaks in function blocks .Sh SYNOPSIS +.Fd using \&Fn: .Ft my_long_return_type * .Fn my_long_function "my_long_type first_argument" "my_long_type second_argument" +.Fd using \&Fo and single-argument \&Fa: +.Ft my_long_return_type * +.Fo my_long_function +.Fa "my_long_type first_argument" +.Fa "my_long_type second_argument" +.Fc +.Fd using \&Fo and multi-argument \&Fa: +.Ft my_long_return_type * +.Fo my_long_function +.Fa "my_long_type first_argument" "my_long_type second_argument" +.Fc .Sh DESCRIPTION +using Fn: +.br .Fn my_long_function "my_long_type first_argument" "my_long_type second_argument" +.Pp +using Fo and single-argument Fa: +.br +.Fo my_long_function +.Fa "my_long_type first_argument" +.Fa "my_long_type second_argument" +.Fc +.Pp +using Fo and multi-argument Fa: +.br +.Fo my_long_function +.Fa "my_long_type first_argument" "my_long_type second_argument" +.Fc diff --git a/regress/usr.bin/mandoc/mdoc/Fo/break.out_ascii b/regress/usr.bin/mandoc/mdoc/Fo/break.out_ascii index a3379b74989..0da37375db2 100644 --- a/regress/usr.bin/mandoc/mdoc/Fo/break.out_ascii +++ b/regress/usr.bin/mandoc/mdoc/Fo/break.out_ascii @@ -4,12 +4,35 @@ NNAAMMEE FFoo--bbrreeaakk - line breaks in function blocks SSYYNNOOPPSSIISS + uussiinngg FFnn:: + + _m_y___l_o_n_g___r_e_t_u_r_n___t_y_p_e _* + mmyy__lloonngg__ffuunnccttiioonn(_m_y___l_o_n_g___t_y_p_e _f_i_r_s_t___a_r_g_u_m_e_n_t, + _m_y___l_o_n_g___t_y_p_e _s_e_c_o_n_d___a_r_g_u_m_e_n_t); + + uussiinngg FFoo aanndd ssiinnggllee--aarrgguummeenntt FFaa:: + + _m_y___l_o_n_g___r_e_t_u_r_n___t_y_p_e _* + mmyy__lloonngg__ffuunnccttiioonn(_m_y___l_o_n_g___t_y_p_e _f_i_r_s_t___a_r_g_u_m_e_n_t, + _m_y___l_o_n_g___t_y_p_e _s_e_c_o_n_d___a_r_g_u_m_e_n_t); + + uussiinngg FFoo aanndd mmuullttii--aarrgguummeenntt FFaa:: + _m_y___l_o_n_g___r_e_t_u_r_n___t_y_p_e _* mmyy__lloonngg__ffuunnccttiioonn(_m_y___l_o_n_g___t_y_p_e _f_i_r_s_t___a_r_g_u_m_e_n_t, _m_y___l_o_n_g___t_y_p_e _s_e_c_o_n_d___a_r_g_u_m_e_n_t); DDEESSCCRRIIPPTTIIOONN + using Fn: mmyy__lloonngg__ffuunnccttiioonn(_m_y___l_o_n_g___t_y_p_e _f_i_r_s_t___a_r_g_u_m_e_n_t, _m_y___l_o_n_g___t_y_p_e _s_e_c_o_n_d___a_r_g_u_m_e_n_t) + using Fo and single-argument Fa: + mmyy__lloonngg__ffuunnccttiioonn(_m_y___l_o_n_g___t_y_p_e _f_i_r_s_t___a_r_g_u_m_e_n_t, + _m_y___l_o_n_g___t_y_p_e _s_e_c_o_n_d___a_r_g_u_m_e_n_t) + + using Fo and multi-argument Fa: + mmyy__lloonngg__ffuunnccttiioonn(_m_y___l_o_n_g___t_y_p_e _f_i_r_s_t___a_r_g_u_m_e_n_t, + _m_y___l_o_n_g___t_y_p_e _s_e_c_o_n_d___a_r_g_u_m_e_n_t) + OpenBSD December 25, 2013 OpenBSD diff --git a/usr.bin/mandoc/mdoc_man.c b/usr.bin/mandoc/mdoc_man.c index 5b713b3a596..5fe505283be 100644 --- a/usr.bin/mandoc/mdoc_man.c +++ b/usr.bin/mandoc/mdoc_man.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_man.c,v 1.55 2013/12/25 00:39:13 schwarze Exp $ */ +/* $Id: mdoc_man.c,v 1.56 2013/12/25 22:00:34 schwarze Exp $ */ /* * Copyright (c) 2011, 2012, 2013 Ingo Schwarze * @@ -1026,13 +1026,16 @@ post_eo(DECL_ARGS) static int pre_fa(DECL_ARGS) { + int am_Fa; - if (MDOC_Fa == n->tok) + am_Fa = MDOC_Fa == n->tok; + + if (am_Fa) n = n->child; while (NULL != n) { font_push('I'); - if (MDOC_SYNPRETTY & n->flags) + if (am_Fa || MDOC_SYNPRETTY & n->flags) outflags |= MMAN_nbrword; print_node(meta, n); font_pop(); @@ -1133,6 +1136,8 @@ pre_fo(DECL_ARGS) pre_syn(n); break; case (MDOC_HEAD): + if (MDOC_SYNPRETTY & n->flags) + print_block(".HP 4n", MMAN_nl); font_push('B'); break; case (MDOC_BODY): @@ -1145,7 +1150,7 @@ pre_fo(DECL_ARGS) } return(1); } - + static void post_fo(DECL_ARGS) { -- 2.20.1