Problem / Motivation:
Building the documentation can be time consuming, because every time it has to rebuild all the languages defined in languages.txt. In the case that you are translating, you might be working and modifying just one language.

Solution:
This little patch provides a way to specify a list of languages to build to the mkoutput.sh script, so you can only rebuild one language. In my case, i want to rebuild just the spanish documentation, since i am working on it's translation.

# Usage:
# "./mkoutput.sh" without parameters will build all the languages defined in languages.txt
# "./mkoutput.sh lang1 lang2 lang3" will build the documentation for all the languages passed as parameters.
# lang1 lang2 lang3 represent valid language codes.

For example:
"./mkoutput.sh es" would just build the spanish docs.

Should be a fairly trivial change, but wanted to get some feedback as i am quite new contributing in Drupal. Later the change can also be incorporated into ./mkfeeds.sh, ./mkebooks.sh, etc.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

guiu.rocafort.ferrer created an issue. See original summary.

jhodgdon’s picture

When I want to build just one language or a subset, I usually just locally edit the languages.txt file. Since it's in a Git repository, after I'm done it's easy enough to just do a git checkout languages.txt.

But this seems like a good idea too. Does it work? :) I will test it later and commit it. Thanks!

jhodgdon’s picture

There are 2 other mk(something) scripts that should also be updated in the same way.

guiu.rocafort.ferrer’s picture

I was working a little bit more on this and got some improvements.

I modified the rest of the mk scripts to also accept same parameters.

The mkzips.sh also accepts them after the version parameter, and added a bit of validation to make sure the script is called at least with the version tag.

Also, I created a script mkall.sh to execute all the different mk scripts, with the same custom languages.

All the scripts where tested with different combinations, of parameters, i believe i covered all of them.

I will commit the changes to the repository so you can test them in your local machines.

guiu.rocafort.ferrer’s picture

Status: Needs review » Fixed
jhodgdon’s picture

Hm. The commit you made seems to have added a mkall.sh script but I don't see changes to the other scripts.

Oh I see, the other two commits didn't reference this issue. That's OK.

Thanks!

eojthebrave’s picture

This is super useful. Thanks @guiu.rocafort.ferrer.

jhodgdon’s picture

Status: Fixed » Needs work

The mkzips.sh command no longer works for me. When running it with no args, I get:

+ '[[]' 0 -lt 1 ']]'
./mkzips.sh: line 10: [[]: command not found
+ mkdir -p ../ebooks/zips
./mkzips.sh: line 18: $1: unbound variable

I just edited my local copy to revert the commit... but it needs attention.

jhodgdon’s picture

One note: you are not supposed to run that command with no args -- it requires the version number, but it still shouldn't crash. I didn't try it with the correct args.

guiu.rocafort.ferrer’s picture

Ok, sorry about that. I will have a look in the next hours to fix it.

What should be the behaviour when there is no version number specified ?

jhodgdon’s picture

Well, probably the old script didn't behave well either. Ideally, I think it would give you a message like "You need to provide the version number". The author of the old script (me) didn't bother with nice things like that. ;}

So... we could probably just leave it. I did verify that if you provide the version number, the script works fine.

jhodgdon’s picture

One other minor problem to fix: There are spaces at the ends of some lines. Please remove them -- we don't like end-of-line whitespace in the Drupal project. You can usually set your code editor to remove or highlight end-of-line spaces. Thanks!

jhodgdon’s picture

For reference, here is the other commit that was made for this issue (not automatically linked here):
https://git.drupalcode.org/project/user_guide/commit/01d50888835eefc7d6c...

jhodgdon’s picture

So before the change, if you ran mkzips.sh without specifying the version string, you would get:

+ mkdir -p ../ebooks/zips
./mkzips.sh: line 12: $1: unbound variable

This is not a beautiful error message, but it seems a bit clearer than #9.

It looks like the new script is trying to detect that the argument is missing, but it just isn't working (at least for me):

if [[] $# -lt 1 ]]; then
  echo "You must specify at least one parameter indicating the version"
  echo "Usage: ./mkzips.sh version [ lang1 lang2 lang3 ]"
  exit -1
fi

guiu.rocafort.ferrer’s picture

There was a syntax problem with the conditional checking the parameters.
I corrected it and tested in my local machine. Seems to be corrected, and now it fails properly with the "need to specify one parameter" message.

I also addressed the endline whitespace issues.

jhodgdon’s picture

Status: Needs work » Fixed

Looks good, thanks for the quick action!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.