diff mbox series

[bug#51543,2/2] doc: Improve documentation of the Bash home service

Message ID c72b1663698eb662885e229a711a9e17a4a281a1.1636120778.git.public@yoctocell.xyz
State Accepted
Headers show
Series [bug#51543,1/2] home: services: bash: Add ‘aliases’ field. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Xinglu Chen Nov. 5, 2021, 2:03 p.m. UTC
* doc/guix.texi (Shells Home Services): Document ‘home-bash-extension’
  configuration record.
* gnu/home/services/shells.scm (generate-home-bash-documentation): Extract
  docstrings from ‘home-bash-extension’.
  (home-bash-configuration): Expound on docstrings.

Fixes: <https://issues.guix.gnu.org/50991>
---
 doc/guix.texi                | 44 ++++++++++++++++++++++++++++++++----
 gnu/home/services/shells.scm | 29 ++++++++++++++++--------
 2 files changed, 59 insertions(+), 14 deletions(-)

Comments

Liliana Marie Prikler Nov. 5, 2021, 7:36 p.m. UTC | #1
Hi,

Am Freitag, den 05.11.2021, 15:03 +0100 schrieb Xinglu Chen:
> @item @code{guix-defaults?} (default: @code{#t}) (type: boolean)
> -Add sane defaults like reading @file{/etc/bashrc}, coloring output
> for
> -@code{ls} provided by guix to @file{.bashrc}.
> +Add sane defaults like reading @file{/etc/bashrc} and coloring the
> output of
> +@command{ls} to the end of the @file{.bashrc} file.
Regarding this option, you might want to instead provide a sane-
defaults-bash-service or something along those lines instead of using
an extra field.  However, as this field already existed before, this is
not a blocker for this series.



> [...]
>  @end table
> +@end deftp
> +
> +You can extend the Bash service by using the @code{home-bash-
> extension}
> +configuration record, whose fields most mirror that of
> +@code{home-bash-configuration} (@pxref{home-bash-
> configuration}).  The
> +contents of the extensions will be added to the end of the
> corresponding
> +Bash configuration files (@pxref{Bash Startup Files,,, bash, The GNU
> +Bash Reference Manual}.
> +
> +@deftp {Data Type} home-bash-extension
> +Available @code{home-bash-extension} fields are:
> +
> +@table @asis
> +@item @code{environment-variables} (default: @code{()}) (type:
> alist)
> +Association list of environment variables to set.
> +
> +@item @code{aliases} (default: @code{()}) (type: alist)
> +Association list of aliases to set.
>  
> +@item @code{bash-profile} (default: @code{()}) (type: text-config)
> +List of file-like objects.
> +
> +@item @code{bashrc} (default: @code{()}) (type: text-config)
> +List of file-like objects.
> +
> +@item @code{bash-logout} (default: @code{()}) (type: text-config)
> +List of file-like objects.
> +
> +@end table
>  @end deftp
Is there a reason why this documentation stayed more or less the same? 
I see the fields have an updated documentation, but it appears not to
be reflected here.  Or are strings taken from the [1/2] patch?

Either way, since the data types ought to be already known, you should
write something along the lines of "Additional environment variables to
set.  These will be concatenated with the environment variables from
other extensions and the base service to form one coherent block of
environment variables." and so on, focusing on what it does rather than
what it is.

Cheers
Xinglu Chen Nov. 7, 2021, 11:20 a.m. UTC | #2
Hi,

On Fri, Nov 05 2021, Liliana Marie Prikler wrote:

> Hi,
>
> Am Freitag, den 05.11.2021, 15:03 +0100 schrieb Xinglu Chen:
>> @item @code{guix-defaults?} (default: @code{#t}) (type: boolean)
>> -Add sane defaults like reading @file{/etc/bashrc}, coloring output
>> for
>> -@code{ls} provided by guix to @file{.bashrc}.
>> +Add sane defaults like reading @file{/etc/bashrc} and coloring the
>> output of
>> +@command{ls} to the end of the @file{.bashrc} file.
> Regarding this option, you might want to instead provide a sane-
> defaults-bash-service or something along those lines instead of using
> an extra field.  However, as this field already existed before, this is
> not a blocker for this series.

That sounds like a good idea!

>> [...]
>>  @end table
>> +@end deftp
>> +
>> +You can extend the Bash service by using the @code{home-bash-
>> extension}
>> +configuration record, whose fields most mirror that of
>> +@code{home-bash-configuration} (@pxref{home-bash-
>> configuration}).  The
>> +contents of the extensions will be added to the end of the
>> corresponding
>> +Bash configuration files (@pxref{Bash Startup Files,,, bash, The GNU
>> +Bash Reference Manual}.
>> +
>> +@deftp {Data Type} home-bash-extension
>> +Available @code{home-bash-extension} fields are:
>> +
>> +@table @asis
>> +@item @code{environment-variables} (default: @code{()}) (type:
>> alist)
>> +Association list of environment variables to set.
>> +
>> +@item @code{aliases} (default: @code{()}) (type: alist)
>> +Association list of aliases to set.
>>  
>> +@item @code{bash-profile} (default: @code{()}) (type: text-config)
>> +List of file-like objects.
>> +
>> +@item @code{bashrc} (default: @code{()}) (type: text-config)
>> +List of file-like objects.
>> +
>> +@item @code{bash-logout} (default: @code{()}) (type: text-config)
>> +List of file-like objects.
>> +
>> +@end table
>>  @end deftp
> Is there a reason why this documentation stayed more or less the same? 
> I see the fields have an updated documentation, but it appears not to
> be reflected here.  Or are strings taken from the [1/2] patch?

I didn’t change the docstrings for ‘home-bash-extension’, only for
‘home-bash-configuration’.

> Either way, since the data types ought to be already known, you should
> write something along the lines of "Additional environment variables to
> set.  These will be concatenated with the environment variables from
> other extensions and the base service to form one coherent block of
> environment variables." and so on, focusing on what it does rather than
> what it is.

Yeah, that sounds a lot more informative than the current docstring.
diff mbox series

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index f7312a5b30..002193e994 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -36159,6 +36159,7 @@ 
 
 @subsubheading Bash Home Service
 
+@anchor{home-bash-configuration}
 @deftp {Data Type} home-bash-configuration
 Available @code{home-bash-configuration} fields are:
 
@@ -36167,15 +36168,20 @@ 
 The Bash package to use.
 
 @item @code{guix-defaults?} (default: @code{#t}) (type: boolean)
-Add sane defaults like reading @file{/etc/bashrc}, coloring output for
-@code{ls} provided by guix to @file{.bashrc}.
+Add sane defaults like reading @file{/etc/bashrc} and coloring the output of
+@command{ls} to the end of the @file{.bashrc} file.
 
 @item @code{environment-variables} (default: @code{()}) (type: alist)
-Association list of environment variables to set for the Bash session.
+Association list of environment variables to set for the Bash session.  The
+rules for the @code{home-environment-variables-service-type} apply
+here (@pxref{Essential Home Services}).  The contents of this field will be
+added after the contents of the @code{bash-profile} field.
 
 @item @code{aliases} (default: @code{()}) (type: alist)
-Association list of aliases to set for the Bash session.  The alias will
-automatically be quoted, so something line this:
+Association list of aliases to set for the Bash session.  The aliases
+will be defined after the contents of the @code{bashrc} field has been
+put in the @file{.bashrc} file.  The alias will automatically be quoted,
+so something line this:
 
 @lisp
 '((\"ls\" . \"ls -alF\"))
@@ -36206,7 +36212,35 @@ 
 process for example).
 
 @end table
+@end deftp
+
+You can extend the Bash service by using the @code{home-bash-extension}
+configuration record, whose fields most mirror that of
+@code{home-bash-configuration} (@pxref{home-bash-configuration}).  The
+contents of the extensions will be added to the end of the corresponding
+Bash configuration files (@pxref{Bash Startup Files,,, bash, The GNU
+Bash Reference Manual}.
+
+@deftp {Data Type} home-bash-extension
+Available @code{home-bash-extension} fields are:
+
+@table @asis
+@item @code{environment-variables} (default: @code{()}) (type: alist)
+Association list of environment variables to set.
+
+@item @code{aliases} (default: @code{()}) (type: alist)
+Association list of aliases to set.
 
+@item @code{bash-profile} (default: @code{()}) (type: text-config)
+List of file-like objects.
+
+@item @code{bashrc} (default: @code{()}) (type: text-config)
+List of file-like objects.
+
+@item @code{bash-logout} (default: @code{()}) (type: text-config)
+List of file-like objects.
+
+@end table
 @end deftp
 
 @subsubheading Zsh Home Service
diff --git a/gnu/home/services/shells.scm b/gnu/home/services/shells.scm
index f24e47f762..9b8427da7b 100644
--- a/gnu/home/services/shells.scm
+++ b/gnu/home/services/shells.scm
@@ -323,16 +323,21 @@  (define-configuration home-bash-configuration
    "The Bash package to use.")
   (guix-defaults?
    (boolean #t)
-   "Add sane defaults like reading @file{/etc/bashrc}, coloring output
-for @code{ls} provided by guix to @file{.bashrc}.")
+   "Add sane defaults like reading @file{/etc/bashrc} and coloring the output of
+@command{ls} to the end of the @file{.bashrc} file.")
   (environment-variables
    (alist '())
-   "Association list of environment variables to set for the Bash session."
+   "Association list of environment variables to set for the Bash session.  The
+rules for the @code{home-environment-variables-service-type} apply
+here (@pxref{Essential Home Services}).  The contents of this field will be
+added after the contents of the @code{bash-profile} field."
    serialize-posix-env-vars)
   (aliases
    (alist '())
-   "Association list of aliases to set for the Bash session.  The alias will
-automatically be quoted, so something line this:
+   "Association list of aliases to set for the Bash session.  The aliases will be
+defined after the contents of the @code{bashrc} field has been put in the
+@file{.bashrc} file.  The alias will automatically be quoted, so something line
+this:
 
 @lisp
 '((\"ls\" . \"ls -alF\"))
@@ -646,10 +651,16 @@  (define (generate-home-shell-profile-documentation)
    'home-shell-profile-configuration))
 
 (define (generate-home-bash-documentation)
-  (generate-documentation
-   `((home-bash-configuration
-      ,home-bash-configuration-fields))
-   'home-bash-configuration))
+  (string-append
+   (generate-documentation
+    `((home-bash-configuration
+       ,home-bash-configuration-fields))
+    'home-bash-configuration)
+   "\n\n"
+   (generate-documentation
+    `((home-bash-extension
+       ,home-bash-extension-fields))
+    'home-bash-extension)))
 
 (define (generate-home-zsh-documentation)
   (generate-documentation