You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Erik Huelsmann <eh...@gmail.com> on 2005/11/25 21:12:51 UTC

[PATCH] Doc string update for (de)translation

On 11/24/05, Julian Foad <ju...@btopenworld.com> wrote:
> Erik Huelsmann wrote:
> >
> > Ok. See r17495.
>
> That looks lovely.
>
> > We can take the docstrings from here. I'll post about that in a new thread.
>
> OK.

Here's the patch. It extends some doc strings. I have no idea what
more to put in the log message.  Do you have anything to add?

Thanks!

bye,

Erik.



Index: subversion/include/svn_subst.h
===================================================================
--- subversion/include/svn_subst.h      (revision 17513)
+++ subversion/include/svn_subst.h      (working copy)
@@ -259,10 +259,13 @@


 /**
- * Convenience routine: a variant of svn_subst_translate_stream3()
- * which operates on files.  In addition, it will create/detranslate a special
- * file if @a special is @c TRUE.
+ * Translates the file at path @a *src into a file at path @a *dst.  The
+ * parameters @a *eol_str, @a repair, @a *keywords and @a expand are
+ * defined the same as in svn_subst_translate_stream3().
  *
+ * In addition, it will create a special file from normal form or
+ * translate one to normal form if @a special is @c TRUE.
+ *
  * Copy the contents of file-path @a src to file-path @a dst atomically,
  * either creating @a dst (or overwriting @a dst if it exists), possibly
  * performing line ending and keyword translations.
@@ -355,8 +358,9 @@
                              svn_boolean_t expand,
                              apr_pool_t *pool);

-/** Convenience routine (wrapper around svn_subst_copy_and_translate3)
- * which detranslates the given @a src into @a dst.
+/**
+ * Translates a file @a *src in working copy form to a file @a *dst in
+ * normal form form.
  *
  * The values specified for @a eol_style, @a *eol_str, @a keywords and
  * @a special, should be the ones used to translate the file to its
@@ -368,6 +372,9 @@
  * returned.  By setting @a always_repair_eols to @c TRUE, eols will be
  * made consistent even for those styles which don't have it by default.
  *
+ * @note To translate a file FROM normal form, use
+ *       svn_subst_copy_and_translate3().
+ *
  * @since New in 1.4
  *
  */
Index: subversion/include/svn_wc.h
===================================================================
--- subversion/include/svn_wc.h (revision 17513)
+++ subversion/include/svn_wc.h (working copy)
@@ -64,10 +64,22 @@
  * @{
  */

-  /** Translate from Normal Format; excludes SVN_WC_TRANSLATE_TO_NF */
+  /** Translate from Normal Form.
+   *
+   * The working copy text bases and repository files are stored
+   * in normal form if they have any svn: properties set which
+   * require translation.
+   *
+   * Either this flag or @c SVN_WC_TRANSLATE_FROM_NF should be specified,
+   * but not both.
+   */
 #define SVN_WC_TRANSLATE_FROM_NF                 0x00000000

-  /** Translate to Normal Format; excludes SVN_WC_TRANSLATE_FROM_NF */
+  /** Translate to Normal Form.
+   *
+   * Either this flag or @c SVN_WC_TRANSLATE_FROM_NF should be specified,
+   * but not both.
+   */
 #define SVN_WC_TRANSLATE_TO_NF                   0x00000001

   /** Force repair of eol styles, making sure the output file consistently
@@ -3165,14 +3177,20 @@
 
 /* EOL conversion and keyword expansion. */

-/** Set @a *xlated_path to a path to translated copy of @src
+/** Set @a *xlated_path to a path to a translated copy of @src
  * or to @a src itself if no translation is necessary.
  * That is, if @a versioned_file's properties indicate newline conversion or
  * keyword expansion, point @a *xlated_path to a copy of @a src
  * whose newlines and keywords are converted using the translation
  * as requested by @a flags.
  *
- * Caller can explicitly request a new file to be returned by setting the
+ * When translating to the normal form, inconsistent eol styles will be
+ * repaired when appropriate for the given setting.  When translating
+ * from normal form, no EOL repair is performed (consistency is assumed).
+ * These behaviours can be overridden by specifying either
+ * @c SVN_WC_TRANSLATE_NO_EOL_REPAIR or @c SVN_WC_TRANSLATE_FORCE_EOL_REPAIR.
+ *
+ * The caller can explicitly request a new file to be returned by setting the
  * @c SVN_WC_TRANSLATE_FORCE_COPY flag in @a flags.
  *
  * This function is generally used to get a file that can be compared
@@ -3180,14 +3198,13 @@
  * @c SVN_WC_TRANSLATE_TO_NF is specified, against @a versioned_file itself
  * if @c SVN_WC_TRANSLATE_FROM_NF is specified.
  *
- * Temporary files are created in the temp file area belonging to
- * @a versioned_file.
+ * Output files are created in the temp file area belonging to
+ * @a versioned_file.  By default they will be deleted at pool cleanup.
  *
- * If @c SVN_WC_TRANSLATE_DEL_TEMP_ON_POOL_CLEANUP is specified,
- * a pool cleanup handler is registered on *xlated_p if it points to a
- * temporary file.
+ * If @c SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP is specified, the default
+ * pool cleanup handler to remove @a *xlated_path is not registered.
  *
- * If an error is returned, the effect on @a *xlated_p is undefined.
+ * If an error is returned, the effect on @a *xlated_path is undefined.
  *
  * @since New in 1.4
  */

Re: [OT] Doc string grammar

Posted by Julian Foad <ju...@btopenworld.com>.
kfogel@collab.net wrote:
> Julian Foad <ju...@btopenworld.com> writes:
> 
>>I think from now on I will sit on the fence and say something like "We
>>write in the imperative or infinitive (syntactically identical)".
[...]
> 
> Some people might interpret "infinitive" as including the "to", that is:
> 
>    imperative:  "Translate TARGET according to KEYWORDS."
>    infinitive:  "To translate TARGET according to KEYWORDS."

Good point.  Malcolm pointed that out to me privately, too.  I'll avoid saying 
that.

>    passive:     "TARGET is translated according to KEYWORDS."
> 
> To avoid confusion, I usually say either "imperative" or "active
> voice" (treating them as synonymous).

"Imperative" seems to be the winner.  "Active voice" doesn't achieve the 
distinction that I wanted, which was to avoid using the third person singular 
present active indicative ("Translates target").

Phew!  Anyone got a grammar description for the grammar description language?  :-)

- Julian

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [OT] Doc string grammar [was: [PATCH] Doc string update for (de)translation]

Posted by kf...@collab.net.
Julian Foad <ju...@btopenworld.com> writes:
> It was just my assumption, I suppose, coupled with a feeling that I'd
> heard it said before by someone.  I think of the doc string as being
> implicitly prefixed by something like "The purpose of this function
> is: [to] " + e.g. "Copy a file".
> 
> But now you mention it, when read from the point of view of the caller
> or the interface designer rather than an onlooker, the imperative
> makes just as much sense in that he/she/it is commanding the function
> to do certain things.
> 
> I think from now on I will sit on the fence and say something like "We
> write in the imperative or infinitive (syntactically identical)".
> 
> In the Subversion mail archives I found no mentions of the infinitive,
> and about two mentions of the imperative, and they were for
> descriptions of Subversion commands in the book.  It would be
> interesting to find out which the majority of translators have chosen
> in languages where there is a syntactic difference.  (But not
> interesting enough for me to try to find out :-) )

Some people might interpret "infinitive" as including the "to", that is:

   imperative:  "Translate TARGET according to KEYWORDS."
   infinitive:  "To translate TARGET according to KEYWORDS."
   passive:     "TARGET is translated according to KEYWORDS."

To avoid confusion, I usually say either "imperative" or "active
voice" (treating them as synonymous).

-Karl

-- 
www.collab.net  <>  CollabNet  |  Distributed Development On Demand

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

[OT] Doc string grammar [was: [PATCH] Doc string update for (de)translation]

Posted by Julian Foad <ju...@btopenworld.com>.
(Though a bit off topic, I'll put this back on the list as it's interesting to 
(perhaps a few) other developers.)

Jim Blandy wrote:
> On 11/25/05, Julian Foad <ju...@btopenworld.com> wrote:
> 
>>Minor syle point: we generally use the infinitive (subject-less) form of the
>>verb: "Translate the file" rather than "[This function] Translates the file".
>>(In English, the infinitive form is identical to the imperative (command) form,
>>if that makes it easier.)
> 
> This is interesting.  I had always considered doc strings to be
> written in the imperative.  Since they're syntactically identical, why
> do you say they're in the infinitive?  Is there some sense in which
> that's a better description of what's going on in a docstring?

It was just my assumption, I suppose, coupled with a feeling that I'd heard it 
said before by someone.  I think of the doc string as being implicitly prefixed 
by something like "The purpose of this function is: [to] " + e.g. "Copy a file".

But now you mention it, when read from the point of view of the caller or the 
interface designer rather than an onlooker, the imperative makes just as much 
sense in that he/she/it is commanding the function to do certain things.

I think from now on I will sit on the fence and say something like "We write in 
the imperative or infinitive (syntactically identical)".

In the Subversion mail archives I found no mentions of the infinitive, and 
about two mentions of the imperative, and they were for descriptions of 
Subversion commands in the book.  It would be interesting to find out which the 
majority of translators have chosen in languages where there is a syntactic 
difference.  (But not interesting enough for me to try to find out :-) )

- Julian

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] Doc string update for (de)translation

Posted by Julian Foad <ju...@btopenworld.com>.
Erik Huelsmann wrote:
> 
> Here's the patch. It extends some doc strings. I have no idea what
> more to put in the log message.  Do you have anything to add?

That's all the log message needs to say.

> Index: subversion/include/svn_subst.h
> ===================================================================
> --- subversion/include/svn_subst.h      (revision 17513)
> +++ subversion/include/svn_subst.h      (working copy)
> @@ -259,10 +259,13 @@
> 
> 
>  /**
> - * Convenience routine: a variant of svn_subst_translate_stream3()
> - * which operates on files.  In addition, it will create/detranslate a special
> - * file if @a special is @c TRUE.
> + * Translates the file at path @a *src into a file at path @a *dst.  The

"src" rather than "*src": we regard the pointer as meaning "the string" 
(whereas "*src" implies a single character).  Same for "dst" and in the next 
doc string.

Minor syle point: we generally use the infinitive (subject-less) form of the 
verb: "Translate the file" rather than "[This function] Translates the file". 
(In English, the infinitive form is identical to the imperative (command) form, 
if that makes it easier.)

> + * parameters @a *eol_str, @a repair, @a *keywords and @a expand are
> + * defined the same as in svn_subst_translate_stream3().
>   *
> + * In addition, it will create a special file from normal form or
> + * translate one to normal form if @a special is @c TRUE.
> + *
>   * Copy the contents of file-path @a src to file-path @a dst atomically,
>   * either creating @a dst (or overwriting @a dst if it exists), possibly
>   * performing line ending and keyword translations.
> @@ -355,8 +358,9 @@
>                               svn_boolean_t expand,
>                               apr_pool_t *pool);
> 
> -/** Convenience routine (wrapper around svn_subst_copy_and_translate3)
> - * which detranslates the given @a src into @a dst.
> +/**
> + * Translates a file @a *src in working copy form to a file @a *dst in
> + * normal form form.

Repetition of "form".  You might as well make this sentence and the one in the 
doc string above use the same words to describe "src" and "dst": either "the 
file at path @a src"/"a file at path @a dst" or "the file @a src"/"a file @a dst".

[...]
> Index: subversion/include/svn_wc.h
> ===================================================================
> --- subversion/include/svn_wc.h (revision 17513)
> +++ subversion/include/svn_wc.h (working copy)
> @@ -64,10 +64,22 @@
>   * @{
>   */
> 
> -  /** Translate from Normal Format; excludes SVN_WC_TRANSLATE_TO_NF */
> +  /** Translate from Normal Form.
> +   *
> +   * The working copy text bases and repository files are stored
> +   * in normal form if they have any svn: properties set which
> +   * require translation.

At first I interpreted that sentence as a brief definition of Normal Form, 
rather than just a statement about it, and that set me thinking about it.

Interpreted as a definition, it seems to imply that:

   1a) If a given file doesn't require translation then it doesn't have a 
normal form, and so these functions don't apply to it and shouldn't be used.
   1b) All Normal Forms share the common feature of LF EOLs.  It's not quite 
clear whether they will all have at least one contracted keyword; that depends 
whether this definition applies to files that have e.g. "svn:keywords=Id" but 
no "$Id" present in them.  They certainly won't necessarily have all of their 
keywords contracted, only the ones that are mentioned in "svn:keywords".

I was thinking of another possible definition:

2) Normal Form of any file is the form in which the file is stored in the 
repository (and WC text base).

This implies that:

   2a) The Normal Form (of a given file) does not necessarily have LF line 
endings or contracted keywords.
   2b) Every file has a Normal Form, but there is no feature that is common to 
all Normal Forms.

Do you think we could successfully use definition (2)?  I think it would be 
easier to define and understand, if we can.

But it really doesn't matter right here.  The point was just to have some hint 
  in the doc string about what this term "Normal Form" refers to, and you've 
put enough of a hint there.


> +   *
> +   * Either this flag or @c SVN_WC_TRANSLATE_FROM_NF should be specified,
> +   * but not both.
> +   */
>  #define SVN_WC_TRANSLATE_FROM_NF                 0x00000000
> 
> -  /** Translate to Normal Format; excludes SVN_WC_TRANSLATE_FROM_NF */
> +  /** Translate to Normal Form.
> +   *
> +   * Either this flag or @c SVN_WC_TRANSLATE_FROM_NF should be specified,
> +   * but not both.
> +   */
>  #define SVN_WC_TRANSLATE_TO_NF                   0x00000001
> 
>    /** Force repair of eol styles, making sure the output file consistently
> @@ -3165,14 +3177,20 @@
>  
>  /* EOL conversion and keyword expansion. */
> 
> -/** Set @a *xlated_path to a path to translated copy of @src
> +/** Set @a *xlated_path to a path to a translated copy of @src

"@src" -> "@a src"

>   * or to @a src itself if no translation is necessary.
>   * That is, if @a versioned_file's properties indicate newline conversion or
>   * keyword expansion, point @a *xlated_path to a copy of @a src
>   * whose newlines and keywords are converted using the translation
>   * as requested by @a flags.
>   *
> - * Caller can explicitly request a new file to be returned by setting the
> + * When translating to the normal form, inconsistent eol styles will be

(I suppose consistently writing either "EOL" or "eol" would mean lots of 
changes outside the scope of this patch ... forget I mentioned it.)

> + * repaired when appropriate for the given setting.  When translating
> + * from normal form, no EOL repair is performed (consistency is assumed).
> + * These behaviours can be overridden by specifying either
> + * @c SVN_WC_TRANSLATE_NO_EOL_REPAIR or @c SVN_WC_TRANSLATE_FORCE_EOL_REPAIR.

No: SVN_WC_TRANSLATE_NO_EOL_REPAIR doesn't exist.

[...]


These are just simple fixes so if you want to just revise it and commit it 
that's fine with me.

- Julian

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] Doc string update for (de)translation

Posted by Erik Huelsmann <eh...@gmail.com>.
On 11/26/05, Malcolm Rowe <ma...@farside.org.uk> wrote:
> On Fri, Nov 25, 2005 at 10:12:51PM +0100, Erik Huelsmann wrote:
>
> In addition to what Julian said,
>
> > +   * The working copy text bases and repository files are stored
> > +   * in normal form if they have any svn: properties set which
> > +   * require translation.
>
> I really think it would be better to say that the working copy text-base
> and repository files are _always_ stored in normal form, even if the
> normal form for some of those files is 'no change'.  The reason is
> that we always want callers to translate files to and from normal form
> as appropriate, rather than have them attempt to guess whether the
> translation is required or not.

Well, there is a function (svn_subst_translation_required) which will
tell them when it is, leaving no room for guessing, but, you're right
it should always be used. Changed.

> > -/** Set @a *xlated_path to a path to translated copy of @src
> > +/** Set @a *xlated_path to a path to a translated copy of @src
> >   * or to @a src itself if no translation is necessary.
>
> I think "Set @a *xlated_path to a translated copy of @a src or..." should
> be fine (ditch 'to a path to', and s/@src/@a src).

Done too.

Thanks for the review!

bye,


Erik.

Re: [PATCH] Doc string update for (de)translation

Posted by Malcolm Rowe <ma...@farside.org.uk>.
On Fri, Nov 25, 2005 at 10:12:51PM +0100, Erik Huelsmann wrote:

In addition to what Julian said,

> +   * The working copy text bases and repository files are stored
> +   * in normal form if they have any svn: properties set which
> +   * require translation.

I really think it would be better to say that the working copy text-base
and repository files are _always_ stored in normal form, even if the
normal form for some of those files is 'no change'.  The reason is
that we always want callers to translate files to and from normal form
as appropriate, rather than have them attempt to guess whether the
translation is required or not.

> -/** Set @a *xlated_path to a path to translated copy of @src
> +/** Set @a *xlated_path to a path to a translated copy of @src
>   * or to @a src itself if no translation is necessary.

I think "Set @a *xlated_path to a translated copy of @a src or..." should
be fine (ditch 'to a path to', and s/@src/@a src).

Regards,
Malcolm

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org