Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: support for multi-language tabs #231

Merged
merged 2 commits into from
Jul 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/aws-cdk-docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
sphinx==1.7.5
m2r==0.1.14
m2r==0.1.14
sphinx-tabs==1.1.7
3 changes: 2 additions & 1 deletion packages/aws-cdk-docs/src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'm2r'
'm2r',
'sphinx_tabs.tabs'
]

# Add any paths that contain templates here, relative to this directory.
Expand Down
51 changes: 36 additions & 15 deletions packages/aws-cdk-docs/src/welcome.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,51 @@ We'll explain the code in more detail,
including how to see your |CFN| template before you deploy it,
in :doc:`getting-started`.

.. code-block:: js
.. tabs::

import { App, Stack, StackProps } from '@aws-cdk/core';
import { Topic } from '@aws-cdk/sns';
import { Queue } from '@aws-cdk/sqs';
.. code-tab:: ts

class HelloStack extends Stack {
import { App, Stack, StackProps } from '@aws-cdk/core';
import { Topic } from '@aws-cdk/sns';
import { Queue } from '@aws-cdk/sqs';

class HelloStack extends Stack {
constructor(parent: App, name: string, props?: StackProps) {
super(parent, name, props);
super(parent, name, props);

const topic = new Topic(this, 'MyTopic');
const topic = new Topic(this, 'MyTopic');

const queue = new Queue(this, 'MyQueue', {
visibilityTimeoutSec: 300
});
const queue = new Queue(this, 'MyQueue', {
visibilityTimeoutSec: 300
});

topic.subscribeQueue('TopicToQueue', queue);
topic.subscribeQueue(queue);
}
}
}

.. code-tab:: java

import com.amazonaws.cdk.App;
import com.amazonaws.cdk.Stack;
import com.amazonaws.cdk.StackProps;
import com.amazonaws.cdk.sns.Topic;
import com.amazonaws.cdk.sns.TopicProps;
import com.amazonaws.cdk.sqs.Queue;
import com.amazonaws.cdk.sqs.QueueProps;

public class HelloStack extends Stack {
public HelloStack(final App parent, final String name, final StackProps props) {
super(parent, name, props);

Topic topic = new Topic(this, "MyTopic");

const app = new App(process.argv);
new HelloStack(app, 'hello-cdk');
Queue queue = new Queue(this, "MyQueue", QueueProps.builder()
.withVisibilityTimeoutSec(300)
.build());

process.stdout.write(app.run());
topic.subscribeQueue(queue);
}
}

The process of creating your AWS resources using the |cdk| is straightforward:

Expand Down