From 585de0b1d93ca78007f010b6b5d65a0d420b421f Mon Sep 17 00:00:00 2001 From: Aaron Costley Date: Thu, 15 Nov 2018 12:25:44 -0800 Subject: [PATCH 1/2] chore(build): Always ignore reference docs on flag set. Even if the reference source directory exists, it takes a long time to copy the files. Deleting this directory is not preferable since the generation toime is also long. Therefore, setting the flag will now always skip reference file copying on the BUILD_DOCS_DEV variable being set. --- docs/build-docs.sh | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/docs/build-docs.sh b/docs/build-docs.sh index fc42b4e5cf4eb..3c84481a9d601 100755 --- a/docs/build-docs.sh +++ b/docs/build-docs.sh @@ -59,22 +59,24 @@ echo "Copying generated reference documentation..." rm -fr ${refdocsdir}/ mkdir -p ${refdocsdir} -if [ ! -d "${refsrc}" ]; then - echo "Cannot find ${refsrc} in the root directory of this repo" - echo "Did you run ./pack.sh?" - - if [ -z "${BUILD_DOCS_DEV:-}" ]; then - echo "Cannot build docs without reference. Set BUILD_DOCS_DEV=1 to allow this for development purposes" - exit 1 +if [ -z "${BUILD_DOCS_DEV:-}" ]; then + if [ ! -d "${refsrc}" ]; then + echo "Cannot find ${refsrc} in the root directory of this repo" + echo "Did you run ./pack.sh?" + + if [ -z "${BUILD_DOCS_DEV:-}" ]; then + echo "Cannot build docs without reference. Set BUILD_DOCS_DEV=1 to allow this for development purposes" + exit 1 + fi else - echo "BUILD_DOCS_DEV is set, continuing without reference documentation..." + rsync -av ${refsrc}/ ${refdocsdir}/ + + echo "Generating reference docs toctree under ${refs_index}..." + cat ${refs_index}.template > ${refs_index} + ls -1 ${refdocsdir} | grep '.rst$' | sed -e 's/\.rst//' | sort | xargs -I{} echo " ${refdocs}/{}" >> ${refs_index} fi else - rsync -av ${refsrc}/ ${refdocsdir}/ - - echo "Generating reference docs toctree under ${refs_index}..." - cat ${refs_index}.template > ${refs_index} - ls -1 ${refdocsdir} | grep '.rst$' | sed -e 's/\.rst//' | sort | xargs -I{} echo " ${refdocs}/{}" >> ${refs_index} + echo "BUILD_DOCS_DEV is set, continuing without reference documentation..." fi export CDK_VERSION=$(../tools/pkgtools/bin/cdk-version) From b501fe9f1ff55396cb0a26026b14b5ec5f83551f Mon Sep 17 00:00:00 2001 From: Aaron Costley Date: Thu, 15 Nov 2018 12:26:29 -0800 Subject: [PATCH 2/2] feature(docs): Add getting started documentation for C#. Fixes #696 --- docs/src/getting-started.rst | 154 +++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/docs/src/getting-started.rst b/docs/src/getting-started.rst index 12754244e478e..e423350f3e820 100644 --- a/docs/src/getting-started.rst +++ b/docs/src/getting-started.rst @@ -77,6 +77,17 @@ Create an empty project structure for the |cdk| app. .. tabs:: + .. group-tab:: C# + + Create a new empty, source controlled directory and then create a new + console application. + + .. code-block:: sh + + mkdir HelloCdk + cd HelloCdk + dotnet new console + .. group-tab:: JavaScript Create an empty source-controlled directory for your project and an @@ -192,6 +203,14 @@ library includes the basic classes needed to write |cdk| stacks and apps. .. tabs:: + .. group-tab:: C# + + Install the **Amazon.CDK NuGet** package: + + .. code-block:: sh + + dotnet add package Amazon.CDK + .. group-tab:: JavaScript Install the **@aws-cdk/cdk** package: @@ -232,6 +251,26 @@ class. Create an empty **App**: .. tabs:: + .. group-tab:: C# + + In **Program.cs** + + .. code-block:: c# + + using Amazon.CDK; + + namespace HelloCdk + { + class Program + { + static void Main(string[] args) + { + var myApp = new App(); + myApp.Run(); + } + } + } + .. group-tab:: JavaScript Create the file **bin/hello-cdk.js**: @@ -293,6 +332,14 @@ If needed, compile the code: .. tabs:: + .. group-tab:: C# + + Compile the code using your IDE or via the dotnet CLI: + + .. code-block:: sh + + dotnet build + .. group-tab:: JavaScript No need to compile @@ -358,6 +405,16 @@ your project directory with the following content: .. tabs:: + .. group-tab:: C# + + Define the :code:`--app` option in a **cdk.json** file: + + .. code-block:: json + + { + "app": "dotnet run --project HelloCdk.csproj" + } + .. group-tab:: JavaScript Define the :code:`--app` option in **cdk.json** to execute **hello-cdk.js** @@ -466,6 +523,44 @@ Define a stack and add it to the app. .. tabs:: + .. group-tab:: C# + + Create **MyStack.cs**: + + .. code-block:: c# + + using Amazon.CDK; + + namespace HelloCdk + { + public class MyStack: Stack + { + public MyStack(App parent, string name) : base(parent, name, null) + { + } + } + } + + In **Program.cs**: + + .. code-block:: c# + :emphasize-lines: 10 + + using Amazon.CDK; + + namespace HelloCdk + { + class Program + { + static void Main(string[] args) + { + var myApp = new App(); + new MyStack(myApp, "hello-cdk"); + myApp.Run(); + } + } + } + .. group-tab:: JavaScript In **index.js**: @@ -575,6 +670,12 @@ Compile your program: .. tabs:: + .. group-tab:: C# + + We have configured cdk.json to run "dotnet run", which will + restore dependencies, build, and run your application. + Therefore, you just need to run the CDK command. + .. group-tab:: JavaScript Nothing to compile. @@ -622,6 +723,12 @@ Install the **@aws-cdk/aws-s3** package: .. tabs:: + .. group-tab:: C# + + .. code-block:: sh + + dotnet add package Amazon.CDK.AWS.S3 + .. group-tab:: JavaScript .. code-block:: sh @@ -651,6 +758,30 @@ the :py:class:`Bucket <@aws-cdk/aws-s3.Bucket>` class: .. tabs:: + .. group-tab:: C# + + Create **MyStack.cs**: + + .. code-block:: c# + :emphasize-lines: 2,10,11,12,13 + + using Amazon.CDK; + using Amazon.CDK.AWS.S3; + + namespace HelloCdk + { + public class MyStack : Stack + { + public MyStack(App parent, string name) : base(parent, name, null) + { + new Bucket(this, "MyFirstBucket", new BucketProps + { + Versioned = true + }); + } + } + } + .. group-tab:: JavaScript In **index.js**: @@ -739,6 +870,12 @@ Compile your program: .. tabs:: + .. group-tab:: C# + + We have configured cdk.json to run "dotnet run", which will + restore dependencies, build, and run your application. + Therefore, you just need to run the CDK command. + .. group-tab:: JavaScript Nothing to compile. @@ -818,6 +955,17 @@ Configure the bucket to use KMS managed encryption: .. tabs:: + .. group-tab:: C# + + .. code-block:: c# + :emphasize-lines: 4 + + new Bucket(this, "MyFirstBucket", new BucketProps + { + Versioned = true, + Encryption = BucketEncryption.KmsManaged + }); + .. group-tab:: JavaScript .. code-block:: js @@ -852,6 +1000,12 @@ Compile the program: .. tabs:: + .. group-tab:: C# + + We have configured cdk.json to run "dotnet run", which will + restore dependencies, build, and run your application. + Therefore, you just need to run the CDK command. + .. group-tab:: JavaScript Nothing to compile.