Skip to content

Commit dde80f8

Browse files
authored
Merge pull request #4990 from dojutsu-user/use-sphinx-prompt
Make $ unselectable in docs
2 parents 05a2a4e + e06869e commit dde80f8

13 files changed

+210
-135
lines changed

docs/.rstcheck.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[rstcheck]
2-
ignore_directives=automodule,http:get,tabs,tab
2+
ignore_directives=automodule,http:get,tabs,tab,prompt
33
ignore_roles=djangosetting,setting
44
ignore_messages=(Duplicate implicit target name: ".*")|(Hyperlink target ".*" is not referenced)
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* CSS for sphinx-prompt */
2+
3+
pre.highlight {
4+
border: 1px solid #e1e4e5;
5+
overflow-x: auto;
6+
margin: 1px 0 24px 0;
7+
padding: 12px 12px;
8+
}
9+
10+
pre.highlight span.prompt1 {
11+
font-size: 12px;
12+
line-height: 1.4;
13+
}

docs/api/v2.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ Project list
5353

5454
**Example request**:
5555

56-
.. sourcecode:: bash
56+
.. prompt:: bash $
5757

58-
$ curl https://readthedocs.org/api/v2/project/?slug=pip
58+
curl https://readthedocs.org/api/v2/project/?slug=pip
5959

6060
**Example response**:
6161

@@ -232,9 +232,9 @@ Build list
232232

233233
**Example request**:
234234

235-
.. sourcecode:: bash
235+
.. prompt:: bash $
236236

237-
$ curl https://readthedocs.org/api/v2/build/?project__slug=pip
237+
curl https://readthedocs.org/api/v2/build/?project__slug=pip
238238

239239
**Example response**:
240240

docs/conf.py

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
'djangodocs',
2929
'doc_extensions',
3030
'sphinx_tabs.tabs',
31+
'sphinx-prompt',
3132
]
3233
templates_path = ['_templates']
3334

@@ -82,3 +83,7 @@
8283

8384
# Activate autosectionlabel plugin
8485
autosectionlabel_prefix_document = True
86+
87+
88+
def setup(app):
89+
app.add_stylesheet('css/sphinx_prompt_css.css')

docs/contribute.rst

+14-8
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,26 @@ install `pre-commit`_ and it will automatically run different linting tools
4949
and `yapf`_) to check your changes before you commit them. `pre-commit` will let
5050
you know if there were any problems that is wasn't able to fix automatically.
5151

52-
To run the `pre-commit` command and check your changes::
52+
To run the `pre-commit` command and check your changes:
5353

54-
$ pip install -U pre-commit
55-
$ git add <your-modified-files>
56-
$ pre-commit run
54+
.. prompt:: bash $
5755

58-
or to run against a specific file::
56+
pip install -U pre-commit
57+
git add <your-modified-files>
58+
pre-commit run
5959

60-
$ pre-commit run --files <file.py>
60+
or to run against a specific file:
61+
62+
.. prompt:: bash $
63+
64+
pre-commit run --files <file.py>
6165

6266
`pre-commit` can also be run as a git pre-commit hook. You can set this up
63-
with::
67+
with:
68+
69+
.. prompt:: bash $
6470

65-
$ pre-commit install
71+
pre-commit install
6672

6773
After this installation, the next time you run `git commit` the `pre-commit run`
6874
command will be run immediately and will inform you of the changes and errors.

docs/custom_installs/elasticsearch.rst

+47-25
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ Installing Java
1212
Elasticsearch requires Java 8 or later. Use `Oracle official documentation <http://www.oracle.com/technetwork/java/javase/downloads/index.html>`_.
1313
or opensource distribution like `OpenJDK <http://openjdk.java.net/install/>`_.
1414

15-
After installing java, verify the installation by,::
15+
After installing java, verify the installation by,:
1616

17-
$ java -version
17+
.. prompt:: bash $
18+
19+
java -version
1820

1921
The result should be something like this::
2022

@@ -31,52 +33,68 @@ Elasticsearch can be downloaded directly from elastic.co. For Ubuntu, it's best
3133
RTD currently uses elasticsearch 1.x which can be easily downloaded and installed from `elastic.co
3234
<https://www.elastic.co/downloads/past-releases/elasticsearch-1-3-8/>`_.
3335

34-
Install the downloaded package by following command::
36+
Install the downloaded package by following command:
37+
38+
.. prompt:: bash $
3539

36-
$ sudo apt install .{path-to-downloaded-file}/elasticsearch-1.3.8.deb
40+
sudo apt install .{path-to-downloaded-file}/elasticsearch-1.3.8.deb
3741

3842
Custom setup
3943
------------
4044

41-
You need the icu plugin::
45+
You need the icu plugin:
46+
47+
.. prompt:: bash $
4248

43-
$ elasticsearch/bin/plugin -install elasticsearch/elasticsearch-analysis-icu/2.3.0
49+
elasticsearch/bin/plugin -install elasticsearch/elasticsearch-analysis-icu/2.3.0
4450

4551
Running Elasticsearch from command line
4652
---------------------------------------
4753

48-
Elasticsearch is not started automatically after installation. How to start and stop Elasticsearch depends on whether your system uses SysV init or systemd (used by newer distributions). You can tell which is being used by running this command::
54+
Elasticsearch is not started automatically after installation. How to start and stop Elasticsearch depends on whether your system uses SysV init or systemd (used by newer distributions). You can tell which is being used by running this command:
4955

50-
$ ps -p 1
56+
.. prompt:: bash $
57+
58+
ps -p 1
5159

5260
**Running Elasticsearch with SysV init**
5361

54-
Use the ``update-rc.d command`` to configure Elasticsearch to start automatically when the system boots up::
62+
Use the ``update-rc.d command`` to configure Elasticsearch to start automatically when the system boots up:
63+
64+
.. prompt:: bash $
65+
66+
sudo update-rc.d elasticsearch defaults 95 10
5567

56-
$ sudo update-rc.d elasticsearch defaults 95 10
68+
Elasticsearch can be started and stopped using the service command:
5769

58-
Elasticsearch can be started and stopped using the service command::
70+
.. prompt:: bash $
5971

60-
$ sudo -i service elasticsearch start
61-
$ sudo -i service elasticsearch stop
72+
sudo -i service elasticsearch start
73+
sudo -i service elasticsearch stop
6274

6375
If Elasticsearch fails to start for any reason, it will print the reason for failure to STDOUT. Log files can be found in /var/log/elasticsearch/.
6476

6577
**Running Elasticsearch with systemd**
6678

67-
To configure Elasticsearch to start automatically when the system boots up, run the following commands::
79+
To configure Elasticsearch to start automatically when the system boots up, run the following commands:
6880

69-
$ sudo /bin/systemctl daemon-reload
70-
$ sudo /bin/systemctl enable elasticsearch.service
81+
.. prompt:: bash $
7182

72-
Elasticsearch can be started and stopped as follows::
83+
sudo /bin/systemctl daemon-reload
84+
sudo /bin/systemctl enable elasticsearch.service
7385

74-
$ sudo systemctl start elasticsearch.service
75-
$ sudo systemctl stop elasticsearch.service
86+
Elasticsearch can be started and stopped as follows:
7687

77-
To verify run::
88+
.. prompt:: bash $
7889

79-
$ curl http://localhost:9200
90+
sudo systemctl start elasticsearch.service
91+
sudo systemctl stop elasticsearch.service
92+
93+
To verify run:
94+
95+
.. prompt:: bash $
96+
97+
curl http://localhost:9200
8098

8199

82100
You should get something like::
@@ -97,12 +115,16 @@ You should get something like::
97115
Index the data available at RTD database
98116
----------------------------------------
99117

100-
You need to create the indexes::
118+
You need to create the indexes:
119+
120+
.. prompt:: bash $
121+
122+
python manage.py provision_elasticsearch
101123

102-
$ python manage.py provision_elasticsearch
124+
In order to search through the RTD database, you need to index it into the elasticsearch index:
103125

104-
In order to search through the RTD database, you need to index it into the elasticsearch index::
126+
.. prompt:: bash $
105127

106-
$ python manage.py reindex_elasticsearch
128+
python manage.py reindex_elasticsearch
107129

108130
You are ready to go!

docs/custom_installs/local_rtd_vm.rst

+67-41
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,29 @@ Assumptions and Prerequisites
55
-----------------------------
66

77
* Debian VM provisioned with python 2.7.x
8-
* All python dependencies and setup tools are installed ::
8+
* All python dependencies and setup tools are installed:
99

10-
$ sudo apt-get install python-setuptools
11-
$ sudo apt-get install build-essential
12-
$ sudo apt-get install python-dev
13-
$ sudo apt-get install libevent-dev
14-
$ sudo easy_install pip
10+
.. prompt:: bash $
1511

16-
* Git ::
12+
sudo apt-get install python-setuptools
13+
sudo apt-get install build-essential
14+
sudo apt-get install python-dev
15+
sudo apt-get install libevent-dev
16+
sudo easy_install pip
1717

18-
$ sudo apt-get install git
18+
* Git:
19+
20+
.. prompt:: bash $
21+
22+
sudo apt-get install git
1923

2024
* Git repo is ``git.corp.company.com:git/docs/documentation.git``
2125
* Source documents are in ``../docs/source``
22-
* Sphinx ::
26+
* Sphinx:
2327

24-
$ sudo pip install sphinx
28+
.. prompt:: bash $
29+
30+
sudo pip install sphinx
2531

2632
.. note:: Not using sudo may prevent access. “error: could not create '/usr/local/lib/python2.7/dist-packages/markupsafe': Permission denied”
2733

@@ -31,42 +37,52 @@ Local RTD Setup
3137
Install RTD
3238
~~~~~~~~~~~
3339

34-
To host your documentation on a local RTD installation, set it up in your VM. ::
40+
To host your documentation on a local RTD installation, set it up in your VM:
41+
42+
.. prompt:: bash $
3543

36-
$ mkdir checkouts
37-
$ cd checkouts
38-
$ git clone https://github.com/rtfd/readthedocs.org.git
39-
$ cd readthedocs.org
40-
$ sudo pip install -r requirements.txt
44+
mkdir checkouts
45+
cd checkouts
46+
git clone https://github.com/rtfd/readthedocs.org.git
47+
cd readthedocs.org
48+
sudo pip install -r requirements.txt
4149

4250
Possible Error and Resolution
4351
`````````````````````````````
4452

4553
**Error**: ``error: command 'gcc' failed with exit status 1``
4654

47-
**Resolution**: Run the following commands. ::
55+
**Resolution**: Run the following commands:
56+
57+
.. prompt:: bash $
58+
59+
sudo apt-get update
60+
sudo apt-get install python2.7-dev tk8.5 tcl8.5 tk8.5-dev tcl8.5-dev libxml2-devel libxslt-devel
61+
sudo apt-get build-dep python-imaging --fix-missing
62+
63+
On Debian 8 (jessie) the command is slightly different:
4864

49-
$ sudo apt-get update
50-
$ sudo apt-get install python2.7-dev tk8.5 tcl8.5 tk8.5-dev tcl8.5-dev libxml2-devel libxslt-devel
51-
$ sudo apt-get build-dep python-imaging --fix-missing
65+
.. prompt:: bash $
5266

53-
On Debian 8 (jessie) the command is slightly different ::
67+
sudo apt-get update
68+
sudo apt-get install python2.7-dev tk8.5 tcl8.5 tk8.5-dev tcl8.5-dev libxml2-dev libxslt-dev
69+
sudo apt-get build-dep python-imaging --fix-missing
5470

55-
$ sudo apt-get update
56-
$ sudo apt-get install python2.7-dev tk8.5 tcl8.5 tk8.5-dev tcl8.5-dev libxml2-dev libxslt-dev
57-
$ sudo apt-get build-dep python-imaging --fix-missing
71+
Also don't forget to re-run the dependency installation
5872

59-
Also don't forget to re-run the dependency installation ::
73+
.. prompt:: bash $
6074

61-
$ sudo pip install -r requirements.txt
75+
sudo pip install -r requirements.txt
6276

6377
Configure the RTD Server and Superuser
6478
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6579

66-
1. Run the following commands. ::
80+
1. Run the following commands:
6781

68-
$ ./manage.py migrate
69-
$ ./manage.py createsuperuser
82+
.. prompt:: bash $
83+
84+
./manage.py migrate
85+
./manage.py createsuperuser
7086

7187
2. This will prompt you to create a superuser account for Django. Enter appropriate details. For example: ::
7288

@@ -77,10 +93,12 @@ Configure the RTD Server and Superuser
7793
RTD Server Administration
7894
~~~~~~~~~~~~~~~~~~~~~~~~~
7995

80-
Navigate to the ``../checkouts/readthedocs.org`` folder in your VM and run the following command. ::
96+
Navigate to the ``../checkouts/readthedocs.org`` folder in your VM and run the following command:
97+
98+
.. prompt:: bash $
8199

82-
$ ./manage.py runserver [VM IP ADDRESS]:8000
83-
$ curl -i http://[VM IP ADDRESS]:8000
100+
./manage.py runserver [VM IP ADDRESS]:8000
101+
curl -i http://[VM IP ADDRESS]:8000
84102

85103
You should now be able to log into the admin interface from any PC in your LAN at ``http://[VM IP ADDRESS]:8000/admin`` using the superuser account created in django.
86104

@@ -90,9 +108,11 @@ Go to the dashboard at ``http://[VM IP ADDRESS]:8000/dashboard`` and follow the
90108
Example: ``git.corp.company.com:/git/docs/documentation.git``.
91109
2. Clone the documentation sources from Git in the VM.
92110
3. Navigate to the root path for documentation.
93-
4. Run the following Sphinx commands. ::
111+
4. Run the following Sphinx commands:
112+
113+
.. prompt:: bash $
94114

95-
$ make html
115+
make html
96116

97117
This generates the HTML documentation site using the default Sphinx theme. Verify the output in your local documentation folder under ``../build/html``
98118

@@ -105,24 +125,30 @@ Possible Error and Resolution
105125

106126
**Workaround-1**
107127

108-
1. In your machine, navigate to the ``.ssh`` folder. ::
128+
1. In your machine, navigate to the ``.ssh`` folder:
109129

110-
$ cd .ssh/
111-
$ cat id_rsa
130+
.. prompt:: bash $
131+
132+
cd .ssh/
133+
cat id_rsa
112134

113135
2. Copy the entire Private Key.
114136
3. Now, SSH to the VM.
115-
4. Open the ``id_rsa`` file in the VM. ::
137+
4. Open the ``id_rsa`` file in the VM:
138+
139+
.. prompt:: bash $
116140

117-
$ vim /home/<username>/.ssh/id_rsa
141+
vim /home/<username>/.ssh/id_rsa
118142

119143
5. Paste the RSA key copied from your machine and save file (``Esc``. ``:wq!``).
120144

121145
**Workaround 2**
122146

123-
SSH to the VM using the ``-A`` directive. ::
147+
SSH to the VM using the ``-A`` directive:
148+
149+
.. prompt:: bash $
124150

125-
$ ssh document-vm -A
151+
ssh document-vm -A
126152

127153
This provides all permissions for that particular remote session, which are revoked when you logout.
128154

0 commit comments

Comments
 (0)