Skip to content

invoking docc from toolchains#863

Closed
shilpeegupta14 wants to merge 1 commit intoapple:mainfrom
shilpeegupta14:main
Closed

invoking docc from toolchains#863
shilpeegupta14 wants to merge 1 commit intoapple:mainfrom
shilpeegupta14:main

Conversation

@shilpeegupta14
Copy link
Copy Markdown

Adjusted the generate_docc.sh file to invoke docc from toolchains now.

Motivation:

Now that the DocC ships in toolchains, I adjusted the generate_docc.sh file to invoke docC directly from toolchains. I am making this change in order to learn contributing effectively. I am trying to update the DocC.

Modifications:

  1. changed the prepare and build toolchain(earlier line no 50 to 73) code to directly access docc from toolchains.
  2. modified and wrote
    export TOOLCHAIN=/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2021-11-20-a.xctoolchain.
    cd $TOOLCHAIN/usr/bin/docc

Result:

Screenshot 2021-12-01 at 6 54 03 PM

@swift-server-bot
Copy link
Copy Markdown

Can one of the admins verify this patch?

6 similar comments
@swift-server-bot
Copy link
Copy Markdown

Can one of the admins verify this patch?

@swift-server-bot
Copy link
Copy Markdown

Can one of the admins verify this patch?

@swift-server-bot
Copy link
Copy Markdown

Can one of the admins verify this patch?

@swift-server-bot
Copy link
Copy Markdown

Can one of the admins verify this patch?

@swift-server-bot
Copy link
Copy Markdown

Can one of the admins verify this patch?

@swift-server-bot
Copy link
Copy Markdown

Can one of the admins verify this patch?


export DOCC_HTML_DIR=$docc_render_source_path/dist
# Accessing docc from toolchain
export TOOLCHAIN=/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2021-11-20-a.xctoolchain
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, no, we cannot hardcode the script to a specific path -- it should ask for the toolchain to be set instead for example -- require the TOOLCHAIN var exists.

Copy link
Copy Markdown
Author

@shilpeegupta14 shilpeegupta14 Dec 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this....

if [[ ! -d "$docc_source_path" ]]; then
cd /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2021-11-20-a.xctoolchain
else
echo "TOOLCHAIN var exists."

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shilpeegupta14 - I suspect what you want to do is check to see if the environment variable TOOLCHAIN is already set, and if so - use it. For a linux platform with a nightly swift pre-installed and already added to the relevant paths (such as a docker build from a nightly swift toolchain release), then you won't need to prefix the commands with TOOLCHAIN, as they should be already on the path (I haven't double-checked that hypothesis though).

In either case, you'll want to likely set the DOCC_HTML_DIR environment variable so that docc, however you invoke it, knows where to find its HTML goodies it wants to combine/link with the output.

StackOverflow has a nice reference to this otherwise awkward problem of determining if an environment variable is already set, which amounts to doing something like:
if [ -z ${var+x} ]; then echo "var is unset"; else echo "var is set to '$var'"; fi

Translating that to "require an environment TOOLCHAIN to be set in order to proceed" might be:

if [ -z ${TOOLCHAIN+x} ]; then echo "TOOLCHAIN is unset"; exit(1); fi

Then from there, build up the DOCC_HTML_DIR:

export DOCC_HTML_DIR=${TOOLCHAIN}/usr/share/docc/render/

export DOCC_HTML_DIR=$docc_render_source_path/dist
# Accessing docc from toolchain
export TOOLCHAIN=/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2021-11-20-a.xctoolchain
cd $TOOLCHAIN/usr/bin/docc
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a binary, we don't "cd" it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay so only this much will help
$TOOLCHAIN/usr/bin/docc

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, invoke with $TOOLCHAIN/usr/bin/docc once you've verified that TOOLCHAIN is defined.

@shilpeegupta14
Copy link
Copy Markdown
Author

Adjusted the generate_docc.sh file to invoke docc from toolchains now.

Motivation:

Now that the DocC ships in toolchains, I adjusted the generate_docc.sh file to invoke docC directly from toolchains. I am making this change in order to learn contributing effectively. I am trying to update the DocC.

Modifications:

  1. changed the prepare and build toolchain(earlier line no 50 to 73) code to directly access docc from toolchains.
  2. modified and wrote
 if [ -z ${TOOLCHAIN+x} ]; then 
    echo "TOOLCHAIN is unset"; exit(1); 
 fi
 export DOCC_HTML_DIR = ${TOOLCHAIN}/usr/bin/docc

  1. $TOOLCHAIN/usr/bin/docc

Screenshot 2021-12-04 at 9 51 16 AM

@Kyle-Ye Kyle-Ye mentioned this pull request Dec 11, 2021
echo "Assuming docc-render is built..."
# invoking docc from toolchain
if [-z ${TOOLCHAIN+x} ]; then
echo "TOOLCHAIN is unset"; exit(1);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gives an error on my machine with zsh.

line 52: syntax error near unexpected token `1'

export DOCC_HTML_DIR=${TOOLCHAIN}/usr/bin/docc

export DOCC_HTML_DIR=$docc_render_source_path/dist
$TOOLCHAIN/usr/bin/docc
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling docc seems useless here for me.

What we want is to export the env DOCC_HTML_DIR so that we can use it later when call docc in preview_docc.sh

if [-z ${TOOLCHAIN+x} ]; then
echo "TOOLCHAIN is unset"; exit(1);
fi
export DOCC_HTML_DIR=${TOOLCHAIN}/usr/bin/docc
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DOCC_HTML_DIR should point to the docc-render dist dir or in the toolchain it is located at /usr/share/docc/render

@ktoso ktoso added this to the 0.10.0 - `distributed actor` milestone Dec 12, 2021
@ktoso
Copy link
Copy Markdown
Member

ktoso commented Dec 12, 2021

Replaced by #865

Thanks for the effort @shilpeegupta14, maybe you'll find something else you can contribute;
Thanks @Kyle-Ye for the PR!

@ktoso ktoso closed this Dec 12, 2021
@ktoso ktoso removed this from the 0.10.0 - `distributed actor` milestone Dec 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Since DocC now ships in toolchains, adjust scripts/docs/generate... to not have to download/build docc

5 participants