galaxy-iuc / standards

Documentation for standards and best practices from the Galaxy IUC
http://galaxy-iuc-standards.readthedocs.io/en/latest/
6 stars 16 forks source link

indentation in CDATA blocks like command and help #43

Open peterjc opened 7 years ago

peterjc commented 7 years ago

Cross reference https://github.com/galaxyproject/tools-iuc/pull/1346#discussion_r120591676 from @nsoranzo

Should we have a recommend style for indenting CDATA blocks? I agree with him that excessive indentation of the command tags is undesirable, and likewise for the RST in the help tags having no extra indentation makes copy/paste to and from an RST editor far easier.

My proposal:

Multiple lines of content should be written as follows (example based on tools/trinotate/trinotate.xml), aligned starting flush left rather than following the XML containing tag's indentation:

    <command><![CDATA[
#if str($cond_download.select_download) == "yes":
    wget --no-verbose 'https://data.broadinstitute.org/Trinity/Trinotate_v3_RESOURCES/Trinotate_v3.sqlite.gz' -O Trinotate.sqlite.gz &&
    gunzip Trinotate.sqlite.gz &&
#else:
    ln -s '$cond_download.trinotate_sqlite_in' Trinotate.sqlite
#end if

Trinotate Trinotate.sqlite init --gene_trans_map '$gene_trans_map' --transcript_fasta $trinity --transdecoder_pep '$transdecoder' &&
#if $blastp:
    Trinotate Trinotate.sqlite LOAD_swissprot_blastp '$blastp' &&
#end if
#if $blastx:
    Trinotate Trinotate.sqlite LOAD_swissprot_blastx '$blastx' &&
#end if
#if $hmmscan:
    Trinotate Trinotate.sqlite LOAD_pfam '$hmmscan' &&
#end if
#if $tmhmm:
    Trinotate Trinotate.sqlite LOAD_tmhmm '$tmhmm' &&
#end if
#if $signalp:
    Trinotate Trinotate.sqlite LOAD_signalp '$signalp' &&
#end if

Trinotate Trinotate.sqlite report -E $report_option.E --pfam_cutoff $report_option.pfam_cutoff $report_option.incl_pep $report_option.incl_trans > '$trinotate_out';
    ]]></command>

Do not use a new line for the opening <![CDATA[ text nor the closing ]]> text.

Do not leave a blank line after the opening tag and <![CDATA[, nor leave a blank line before the closing ]]> and closing tag.

Single lines of content may be written as either:

<command><![CDATA[perl $__tool_directory__/xpath -q -e '$expression' $input > $output]]></command>

(example from tools/xpath/xpath.xml), or following the recommenced multi-line style:

    <command><![CDATA[
perl $__tool_directory__/xpath -q -e '$expression' $input > $output
    ]]></command>
bgruening commented 7 years ago

@peterjc go ahead and make a PR :)

nsoranzo commented 7 years ago

:100:

peterjc commented 7 years ago

Note that right now the tools-iuc XML files have a range of usage here - and its the kind of change while it is trivial in theory, it would be easy to accidentally break things.

nsoranzo commented 7 years ago

Indentation is not significant in Cheetah, so this kind of changes shouldn't have any impact.

Any way I'm happy to have this as a suggested (not mandatory) code style.

mvdbeek commented 6 years ago

👍