
    ~                         S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJr  SSK	J
r
  SS	KJr  SS
KJr  SSKJr   " S S\R                   5      r " S S\R$                  5      rg)zCA command that generates and/or updates help document directoriess.    )absolute_import)division)unicode_literalsN)base)walker_util)	help_util)
exceptions)log)console_attrc                       \ rS rSrSrSrg)HelpOutOfDateError    z&Help documents out of date for --test. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       &lib/surface/meta/generate_help_docs.pyr   r       s    .r   r   c                   .    \ rS rSrSr\S 5       rS rSrg)GenerateHelpDocs$   a  Generate and/or update help document directories.

The DevSite docs are generated in the --devsite-dir directory with pathnames
in the reference directory hierarchy. The manpage docs are generated in the
--manpage-dir directory with pathnames in the manN/ directory hierarchy.
c                 b   U R                  SSSSS9  U R                  SSSS	9  U R                  S
SSS	9  U R                  SSSS	9  U R                  SSSS	9  U R                  SSSS	9  U R                  SSSS9  U R                  SSSSS9  U R                  SSSSS9  U R                  SSSS SS9  g ) Nz--hidden
store_trueFz1Include documents for hidden commands and groups.)actiondefaulthelpz--devsite-dir	DIRECTORYzThe directory where the generated DevSite reference document subtree will be written. If not specified then DevSite documents will not be generated.)metavarr   z--help-text-dirzThe directory where the generated help text reference document subtree will be written. If not specified then help text documents will not be generated. The --hidden flag is implied for --help-text-dir.z
--html-dira  The directory where the standalone manpage HTML files will be generated. index.html contains manpage tree navigation in the left pane. The active command branch and its immediate children are visible and clickable. Hover to navigate the tree. Run `python -m http.server 8888 &` in DIRECTORY and point your browser at [](http://localhost:8888) to view the manpage tree. If not specified then the HTML manpage site will not be generated.z--linter-dirzThe directory where the generated documentation linter errors for the help text reference document subtree will be written. If not specified then documentation linter documents will not be generated.z--manpage-dirzThe directory where the generated manpage document subtree will be written. The manpage hierarchy is flat with all command documents in the manN/ subdirectory. If not specified then manpage documents will not be generated.z--testzqShow but do not apply --update actions. Exit with non-zero exit status if any help document file must be updated.)r   r   z--updatezUpdate destination directories to match the current CLI. Documents for commands not present in the current CLI will be deleted. Use this flag to update the help text golden files after the help_text_test test fails.z--update-help-text-dirTz;Deprecated. Use --update --help-text-dir=DIRECTORY instead.)hiddenr!   r   restrictzCOMMAND/GROUP*zRestrict document generation to these dotted command paths.
              For example:

                gcloud.alpha gcloud.beta.test

              OR

                gcloud.{alpha.,beta.,}compute.instances
              )r!   nargsr   r   )add_argument)parsers    r   ArgsGenerateHelpDocs.Args,   sO   
A	  D
 1  3 %  '   
     9  ; B  D
 5	  7  J	  L
   r   c                   ^ ^^ [        5       mSUUU 4S jjnTR                  (       aE  [        R                  " SR	                  TR                  S95        TR                  Tl        STl        TR                  (       a+  U" S[        R                  TR                  TR                  S9  TR
                  (       a"  U" S[        R                  TR
                  SSS9  TR                  (       a+  U" S	[        R                  TR                  TR                  S9  TR                  (       a+  U" S
[        R                  TR                  TR                  S9  TR                   (       a+  U" S[        R"                  TR                   TR                  S9  T(       at  TR$                  (       ab  ['        T5      n[)        U5      S:  a)  SR+                  SR+                  US S 5      US   /5      nOUS   n[-        SR	                  U5      5      eg g )Nc                   > TR                    Vs/ s H  n[        R                  " SSU5      PM     nn[        R                  " U5        TR
                  (       d!  U" T	R                  X&S9R                  XF5        g[        R                  " T	R                  X!TR                  US9R                  U5      (       a  TR                  U 5        ggs  snf )z=Runs generator and optionally updates help docs in directory._-)r#   )testr"   N)r#   resubr   ResetConsoleAttrupdate_cli_power_users_onlyWalkr   HelpUpdaterr.   Updateadd)
kind	generator	directoryencodingr"   prestrict_dirargsout_of_dateselfs
          r   Generate&GenerateHelpDocs.Run.<locals>.Generate}   s    59]]C]bffT4+]lC##H-[[&&		

$v
$  

$
$iyy))/)=> 	> Ds   "Czk[--update-help-text-dir={directory}] is deprecated. Use this instead: --update --help-text-dir={directory}.)r:   TDevSite)r"   z	help textasciihtmlzman pagezcommand linter   z and z, r   z"{} document files must be updated.)zutf-8F)setupdate_help_text_dirr
   warningformathelp_text_dirr2   devsite_dirr   DevSiteGeneratorr"   HelpTextGeneratorhtml_dirHtmlGeneratormanpage_dirManPageGenerator
linter_dirLinterGeneratorr.   sortedlenjoinr   )r@   r>   rA   nameskindsr?   s   ``   @r   RunGenerateHelpDocs.Runz   s   %K    	kk HHN $ 9 9 IO I;<  44ddk y+668H8Hkk#{K994;M;Mt%}}v{00$--kk#z;779I9Ikk#!<!<dookk#
 tyy[!e	Uadiicr
3U2Y?@a
.
5
5e
<> > !{r   r   N)	r   r   r   r   r   staticmethodr(   r[   r   r   r   r   r   r   $   s#     K KZ4>r   r   )r   
__future__r   r   r   r/   googlecloudsdk.callioper   r   googlecloudsdk.command_lib.metar   googlecloudsdk.corer	   r
   googlecloudsdk.core.consoler   Errorr   Commandr   r   r   r   <module>re      sM     J &  ' 	 ( / 5 * # 4/)) /J>t|| J>r   