Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
docs: Add syntax highlighting languages to code blocks.
Anders Kaseorgb29b6f652614
diff --git a/docs/contributing/accessibility.md b/docs/contributing/accessibility.mdindex dec4b7baaba..e960852d0c0 100644--- a/docs/contributing/accessibility.md+++ b/docs/contributing/accessibility.md@@ -60,7 +60,7 @@ Problems with Zulip's accessibility should be reported aslabel. This label can be added by entering the following text in a separatecomment on the issue:- @zulipbot add "area: accessibility"+> @zulipbot add "area: accessibility"If you want to help make Zulip more accessible, here is a list of the[currently open accessibility issues][accessibility-issues].diff --git a/docs/contributing/code-style.md b/docs/contributing/code-style.mdindex fb2a655f7b8..304725fa687 100644--- a/docs/contributing/code-style.md+++ b/docs/contributing/code-style.md@@ -34,11 +34,15 @@ When in doubt, ask in [chat.zulip.org](https://chat.zulip.org).You can run them all at once with- ./tools/lint+```bash+./tools/lint+```You can set this up as a local Git commit hook with- tools/setup-git-repo+```bash+tools/setup-git-repo+```The Vagrant setup process runs this for you.@@ -66,17 +70,21 @@ to read secrets from `/etc/zulip/secrets.conf`.Look out for Django code like this:- bars = Bar.objects.filter(...)- for bar in bars:- foo = bar.foo- # Make use of foo+```python+bars = Bar.objects.filter(...)+for bar in bars:+ foo = bar.foo+ # Make use of foo+```...because it equates to:- bars = Bar.objects.filter(...)- for bar in bars:- foo = Foo.objects.get(id=bar.foo.id)- # Make use of foo+```python+bars = Bar.objects.filter(...)+for bar in bars:+ foo = Foo.objects.get(id=bar.foo.id)+ # Make use of foo+```...which makes a database query for every Bar. While this may be fastlocally in development, it may be quite slow in production! Instead,@@ -84,10 +92,12 @@ tell Django's [QuerySetAPI](https://docs.djangoproject.com/en/dev/ref/models/querysets/) to_prefetch_ the data in the initial query:- bars = Bar.objects.filter(...).select_related()- for bar in bars:- foo = bar.foo # This doesn't take another query, now!- # Make use of foo+```python+bars = Bar.objects.filter(...).select_related()+for bar in bars:+ foo = bar.foo # This doesn't take another query, now!+ # Make use of foo+```If you can't rewrite it as a single query, that's a sign that somethingis wrong with the database schema. So don't defer this optimization when@@ -118,7 +128,7 @@ different database queries:For example, the following will, surprisingly, fail:-```+```python# Bad example -- will raise!obj: UserProfile = get_user_profile_by_id(17)some_objs = UserProfile.objects.get(id=17)@@ -127,7 +137,7 @@ assert obj in set([some_objs])You should work with the IDs instead:-```+```pythonobj: UserProfile = get_user_profile_by_id(17)some_objs = UserProfile.objects.get(id=17)assert obj.id in set([o.id for i in some_objs])@@ -266,18 +276,24 @@ The best way to build complicated DOM elements is a Mustache templatelike `static/templates/message_reactions.hbs`. For simpler thingsyou can use jQuery DOM building APIs like so:- var new_tr = $('<tr />').attr('id', object.id);+```js+var new_tr = $('<tr />').attr('id', object.id);+```Passing a HTML string to jQuery is fine for simple hardcoded thingsthat don't need internationalization:- foo.append('<p id="selected">/</p>');+```js+foo.append('<p id="selected">/</p>');+```but avoid programmatically building complicated strings.We used to favor attaching behaviors in templates like so:- <p onclick="select_zerver({{id}})">+```js+<p onclick="select_zerver({{id}})">+```but there are some reasons to prefer attaching events using jQuery code:@@ -328,8 +344,10 @@ type changes in the future.reason to do otherwise.- Unpacking sequences doesn't require list brackets:- [x, y] = xs # unnecessary- x, y = xs # better+ ```python+ [x, y] = xs # unnecessary+ x, y = xs # better+ ```- For string formatting, use `x % (y,)` rather than `x % y`, to avoidambiguity if `y` happens to be a tuple.diff --git a/docs/development/remote.md b/docs/development/remote.mdindex 523e64a218b..bbd235a2c76 100644--- a/docs/development/remote.md+++ b/docs/development/remote.md@@ -21,7 +21,7 @@ The best way to connect to your server is using the command line tool `ssh`.Open *Terminal* or *Bash for Git*, and connect with the following:-```+```console$ ssh username@host```@@ -75,7 +75,7 @@ Once you have set up the development environment, you can start up thedevelopment server with the following command in the directory whereyou cloned Zulip:-```+```bash./tools/run-dev.py --interface=''```@@ -98,7 +98,7 @@ such as a DigitalOcean Droplet or an AWS EC2 instance, you can set upport-forwarding to access Zulip by running the following command inyour terminal:-```+```bashssh -L 3000:127.0.0.1:9991 <username>@<remote_server_ip> -N```@@ -202,7 +202,7 @@ developing locally.1. Install the extension[Remote VSCode](https://marketplace.visualstudio.com/items?itemName=rafaelmaiolla.remote-vscode).2. On your remote machine, run:- ```+ ```console$ mkdir -p ~/bin$ curl -fL -o ~/bin/rmate https://raw.githubusercontent.com/textmate/rmate/master/bin/rmate$ chmod a+x ~/bin/rmate@@ -210,11 +210,11 @@ developing locally.3. Make sure the remote server is running in VS Code (you canforce-start through the Command Palette).4. SSH to your remote machine using- ```+ ```console$ ssh -R 52698:localhost:52698 [email protected]```5. On your remote machine, run- ```+ ```console$ rmate [options] file```and the file should open up in VS Code. Any changes you make now will be saved remotely.@@ -292,7 +292,7 @@ different.1. First, get an SSL certificate; you can use[our certbot wrapper script used for production](../production/ssl-certificates.html#certbot-recommended)by running the following commands as root:- ```+ ```bash# apt install -y crudinimkdir -p /var/lib/zulip/certbot-webroot/# if nginx running this will fail and you need to run `service nginx stop`@@ -303,7 +303,7 @@ different.1. Install nginx configuration:- ```+ ```bashapt install -y nginx-fullcp -a /home/zulipdev/zulip/tools/droplets/zulipdev /etc/nginx/sites-available/ln -nsf /etc/nginx/sites-available/zulipdev /etc/nginx/sites-enabled/@@ -316,6 +316,6 @@ different.will be HTTPS.1. Start the Zulip development environment with the following command:- ```+ ```bashenv EXTERNAL_HOST="hostname.example.com" ./tools/run-dev.py --interface=''```diff --git a/docs/development/setup-advanced.md b/docs/development/setup-advanced.mdindex ef1f607c478..256b39d2863 100644--- a/docs/development/setup-advanced.md+++ b/docs/development/setup-advanced.md@@ -35,13 +35,13 @@ just do `vagrant destroy` to clean up the development environment.Start by [cloning your fork of the Zulip repository][zulip-rtd-git-cloning]and [connecting the Zulip upstream repository][zulip-rtd-git-connect]:-```+```bashgit clone --config pull.rebase [email protected]:YOURUSERNAME/zulip.gitcd zulipgit remote add -f upstream https://github.com/zulip/zulip.git```-```+```bash# On CentOS/RHEL, you must first install epel-release, and then python36,# and finally you must run `sudo ln -nsf /usr/bin/python36 /usr/bin/python3`# On Fedora, you must first install python3@@ -70,20 +70,20 @@ installation method described here.1. Launch the `Ubuntu 18.04` shell and run the following commands:- ```+ ```bashsudo apt update && sudo apt upgradesudo apt install rabbitmq-server memcached redis-server postgresql```1. Open `/etc/rabbitmq/rabbitmq-env.conf` using e.g.:- ```+ ```bashsudo vim /etc/rabbitmq/rabbitmq-env.conf```Add the following lines at the end of your file and save:- ```+ ```iniNODE_IP_ADDRESS=127.0.0.1NODE_PORT=5672```@@ -91,14 +91,14 @@ installation method described here.1. Make sure you are inside the WSL disk and not in a Windows mounted disk.You will run into permission issues if you run `provision` from `zulip`in a Windows mounted disk.- ```+ ```bashcd ~ # or cd /home/USERNAME```1. [Clone your fork of the Zulip repository][zulip-rtd-git-cloning]and [connecting the Zulip upstream repository][zulip-rtd-git-connect]:- ```+ ```bashgit clone --config pull.rebase [email protected]:YOURUSERNAME/zulip.git ~/zulipcd zulipgit remote add -f upstream https://github.com/zulip/zulip.git@@ -108,7 +108,7 @@ installation method described here.start it (click `Allow access` if you get popups for Windows Firewallblocking some services)- ```+ ```bash# Start database, cache, and other services./tools/wsl/start_services# Install/update the Zulip development environment@@ -152,7 +152,7 @@ expected.1. Start by [cloning your fork of the Zulip repository][zulip-rtd-git-cloning]and [connecting the Zulip upstream repository][zulip-rtd-git-connect]:- ```+ ```bashgit clone --config pull.rebase [email protected]:YOURUSERNAME/zulip.gitcd zulipgit remote add -f upstream https://github.com/zulip/zulip.git@@ -167,7 +167,7 @@ expected.You should get output like this:- ```text+ ```consoleBringing machine 'default' up with 'hyperv' provider...==> default: Verifying Hyper-V is enabled...==> default: Verifying Hyper-V is accessible...@@ -201,14 +201,14 @@ expected.1. Set the `EXTERNAL_HOST` environment variable.- ```bash+ ```console(zulip-py3-venv) vagrant@ubuntu-18:/srv/zulip$ export EXTERNAL_HOST="$(hostname -I | xargs):9991"(zulip-py3-venv) vagrant@ubuntu-18:/srv/zulip$ echo $EXTERNAL_HOST```The output will be like:- ```text+ ```console172.28.122.156:9991```@@ -223,13 +223,13 @@ expected.1. You should now be able to start the Zulip development server.- ```bash+ ```console(zulip-py3-venv) vagrant@ubuntu-18:/srv/zulip$ ./tools/run-dev.py```The output will look like:- ```text+ ```consoleStarting Zulip on:http://172.30.24.235:9991/diff --git a/docs/development/setup-vagrant.md b/docs/development/setup-vagrant.mdindex b94dd55b2d9..ac5cf8825c3 100644--- a/docs/development/setup-vagrant.md+++ b/docs/development/setup-vagrant.md@@ -102,14 +102,14 @@ Mac](https://docs.docker.com/docker-for-mac/install/).##### 1. Install Vagrant, Docker, and Git-```+```consolechristie@ubuntu-desktop:~$ sudo apt install vagrant docker.io git```##### 2. Add yourself to the `docker` group:-```+```consolechristie@ubuntu-desktop:~$ sudo adduser $USER dockerAdding user `christie' to group `docker' ...@@ -120,7 +120,7 @@ Done.You will need to reboot for this change to take effect. If it worked,you will see `docker` in your list of groups:-```+```consolechristie@ubuntu-desktop:~$ groups | grep dockerchristie adm cdrom sudo dip plugdev lpadmin sambashare docker@@ -134,7 +134,7 @@ bug](https://bugs.launchpad.net/ubuntu/+source/docker.io/+bug/1844894)may prevent Docker from being automatically enabled and started afterinstallation. You can check using the following:-```+```console$ systemctl status docker● docker.service - Docker Application Container EngineLoaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)@@ -145,7 +145,7 @@ If the service is not running, you'll see `Active: inactive (dead)` onthe second line, and will need to enable and start the Docker serviceusing the following:-```+```bashsudo systemctl unmask dockersudo systemctl enable dockersudo systemctl start docker@@ -196,13 +196,13 @@ In **Git for BASH**:Open **Git BASH as an administrator** and run:-```+```console$ git config --global core.symlinks true```Now confirm the setting:-```+```console$ git config core.symlinkstrue```@@ -217,7 +217,7 @@ In **Cygwin**:Open a Cygwin window **as an administrator** and do this:-```+```consolechristie@win10 ~$ echo 'export "CYGWIN=$CYGWIN winsymlinks:native"' >> ~/.bash_profile```@@ -225,7 +225,7 @@ $ echo 'export "CYGWIN=$CYGWIN winsymlinks:native"' >> ~/.bash_profileNext, close that Cygwin window and open another. If you `echo` $CYGWIN youshould see:-```+```consolechristie@win10 ~$ echo $CYGWINwinsymlinks:native@@ -251,7 +251,7 @@ projects and to instead follow these instructions exactly.)[clone your fork of the Zulip repository](../git/cloning.html#step-1b-clone-to-your-machine) and[connect the Zulip upstream repository](../git/cloning.html#step-1c-connect-your-fork-to-zulip-upstream):-```+```bashgit clone --config pull.rebase [email protected]:YOURUSERNAME/zulip.gitcd zulipgit remote add -f upstream https://github.com/zulip/zulip.git@@ -262,7 +262,7 @@ This will create a 'zulip' directory and download the Zulip code into it.Don't forget to replace YOURUSERNAME with your Git username. You will seesomething like:-```+```consolechristie@win10 ~$ git clone --config pull.rebase [email protected]:YOURUSERNAME/zulip.gitCloning into 'zulip'...@@ -283,7 +283,7 @@ environment](#step-3-start-the-development-environment).Change into the zulip directory and tell vagrant to start the Zulipdevelopment environment with `vagrant up`:-```+```bash# On Windows or macOS (Intel):cd zulipvagrant plugin install vagrant-vbguest@@ -327,14 +327,14 @@ specified.` several times. This is normal and is not a problem.Once `vagrant up` has completed, connect to the developmentenvironment with `vagrant ssh`:-```+```consolechristie@win10 ~/zulip$ vagrant ssh```You should see output that starts like this:-```+```consoleWelcome to Ubuntu 18.04.2 LTS (GNU/Linux 4.15.0-54-generic x86_64)```@@ -347,14 +347,14 @@ provisioning failed and you should look at theNext, start the Zulip server:-```+```console(zulip-py3-venv) vagrant@ubuntu-bionic:/srv/zulip$ ./tools/run-dev.py```You will see several lines of output starting with something like:-```+```console2016-05-04 22:20:33,895 INFO: process_fts_updates startingRecompiling templates2016-05-04 18:20:34,804 INFO: Not in recovery; listening for FTS updates@@ -371,7 +371,7 @@ Performing system checks...```And ending with something similar to:-```+```consolehttp://localhost:9994/webpack-dev-server/webpack result is served from http://localhost:9991/webpack/content is served from /srv/zulip@@ -392,7 +392,7 @@ The Zulip server will continue to run and send output to the terminal window.When you navigate to Zulip in your browser, check your terminal and youshould see something like:-```+```console2016-05-04 18:21:57,547 INFO 127.0.0.1 GET 302 582ms (+start: 417ms) / (unauth@zulip via ?)[04/May/2016 18:21:57]"GET / HTTP/1.0" 302 02016-05-04 18:21:57,568 INFO 127.0.0.1 GET 301 4ms /login (unauth@zulip via ?)@@ -491,7 +491,7 @@ can halt vagrant from another Terminal/Git BASH window.From the window where run-dev.py is running:-```+```console2016-05-04 18:33:13,330 INFO 127.0.0.1 GET 200 92ms /register/ (unauth@zulip via ?)^CKeyboardInterrupt@@ -502,7 +502,7 @@ christie@win10 ~/zulip```Now you can suspend the development environment:-```+```consolechristie@win10 ~/zulip$ vagrant suspend==> default: Saving VM state and suspending execution...@@ -510,7 +510,7 @@ $ vagrant suspendIf `vagrant suspend` doesn't work, try `vagrant halt`:-```+```consolechristie@win10 ~/zulip$ vagrant halt==> default: Attempting graceful shutdown of VM...@@ -527,7 +527,7 @@ pass the `--provider` option required above). You will also need toconnect to the virtual machine with `vagrant ssh` and re-start theZulip server:-```+```consolechristie@win10 ~/zulip$ vagrant up$ vagrant ssh@@ -579,7 +579,7 @@ This is caused by provisioning failing to complete successfully. Youcan see the errors in `var/log/provision.log`; it should end withsomething like this:-```+```textESC[94mZulip development environment setup succeeded!ESC[0m```@@ -596,7 +596,7 @@ shell and run `vagrant ssh` again to get the virtualenv setup properly.#### Vagrant was unable to mount VirtualBox shared foldersFor the following error:-```+```consoleVagrant was unable to mount VirtualBox shared folders. This is usuallybecause the filesystem "vboxsf" is not available. This filesystem ismade available via the VirtualBox Guest Additions and kernel@@ -610,7 +610,7 @@ was:If this error starts happening unexpectedly, then just run:-```+```bashvagrant haltvagrant up```@@ -622,7 +622,7 @@ to reboot the guest. After this, you can do `vagrant provision` andIf you receive the following error while running `vagrant up`:-```+```consoleSSL read: error:00000000:lib(0):func(0):reason(0), errno 104```@@ -634,14 +634,14 @@ better network connection).When running `vagrant up` or `provision`, if you see the following error:-```+```console==> default: E:unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).```It means that your local apt repository has been corrupted, which canusually be resolved by executing the command:-```+```bashapt-get -f install```@@ -649,7 +649,7 @@ apt-get -f installOn running `vagrant ssh`, if you see the following error:-```+```consolessh_exchange_identification: Connection closed by remote host```@@ -662,7 +662,7 @@ for more details.If you receive the following error while running `vagrant up`:-```+```console==> default: Traceback (most recent call last):==> default: File "./emoji_dump.py", line 75, in <module>==> default:@@ -704,7 +704,7 @@ Get the name of your virtual machine by running `vboxmanage list vms` andthen print out the custom settings for this virtual machine with`vboxmanage getextradata YOURVMNAME enumerate`:-```+```consolechristie@win10 ~/zulip$ vboxmanage list vms"zulip_default_1462498139595_55484" {5a65199d-8afa-4265-b2f6-6b1f162f157d}@@ -723,7 +723,7 @@ If `vboxmanage enumerate` prints nothing, or shows a value of 0 forVBoxInternal2/SharedFoldersEnableSymlinksCreate/srv_zulip, then enablesymbolic links by running this command in Terminal/Git BASH/Cygwin:-```+```bashvboxmanage setextradata YOURVMNAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/srv_zulip 1```@@ -737,7 +737,7 @@ Windows is incorrectly attempting to use Hyper-V rather thanVirtualbox as the virtualization provider. You can fix this byexplicitly passing the virtualbox provider to `vagrant up`:-```+```consolechristie@win10 ~/zulip$ vagrant up --provide=virtualbox```@@ -746,7 +746,7 @@ $ vagrant up --provide=virtualboxIf you see the following error after running `vagrant up`:-```+```consoledefault: SSH address: 127.0.0.1:2222default: SSH username: vagrantdefault: SSH auth method: private key@@ -769,7 +769,7 @@ this post](https://stackoverflow.com/questions/22575261/vagrant-stuck-connectionIf you see the following error when you run `vagrant up`:-```+```consoleTimed out while waiting for the machine to boot. This means thatVagrant was unable to communicate with the guest machine withinthe configured ("config.vm.boot_timeout" value) time period.@@ -816,7 +816,7 @@ proxy to access the Internet and haven't [configured the developmentenvironment to use it](#specifying-a-proxy).Once you've provisioned successfully, you'll get output like this:-```+```consoleZulip development environment setup succeeded!(zulip-py3-venv) vagrant@vagrant-base-trusty-amd64:~/zulip$```@@ -843,7 +843,7 @@ the VM.##### yarn install warnings-```+```console$ yarn installyarn install v0.24.5[1/4] Resolving packages...@@ -860,7 +860,7 @@ It is okay to proceed and start the Zulip server.#### VBoxManage errors related to VT-x or WHvSetupPartition-```+```consoleThere was an error while executing `VBoxManage`, a CLI used by Vagrantfor controlling VirtualBox. The command and stderr is shown below.@@ -873,7 +873,7 @@ VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap,or-```+```consoleStderr: VBoxManage.exe: error: Call to WHvSetupPartition failed: ERROR_SUCCESS (Last=0xc000000d/87) (VERR_NEM_VM_CREATE_FAILED)VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole```@@ -889,7 +889,7 @@ later, run `bcdedit /deletevalue hypervisorlaunchtype`, and reboot.#### OSError: [Errno 26] Text file busy-```+```consoledefault: Traceback (most recent call last):…default: File "/srv/zulip-py3-venv/lib/python3.6/shutil.py", line 426, in _rmtree_safe_fd@@ -903,7 +903,7 @@ the VirtualBox Guest Additions for Linux on Windows hosts. You cancheck the running version of VirtualBox Guest Additions with thiscommand:-```+```bashvagrant ssh -- 'modinfo -F version vboxsf'```@@ -912,13 +912,13 @@ able to work around it by downgrading VirtualBox Guest Additions to6.0.4. To do this, create a `~/.zulip-vagrant-config` file and addthis line:-```+```textVBOXADD_VERSION 6.0.4```Then run these commands (yes, reload is needed twice):-```+```bashvagrant plugin install vagrant-vbguestvagrant reloadvagrant reload --provision@@ -934,7 +934,7 @@ a local mirror closer to your location. To do this, create`~/.zulip-vagrant-config` and add a line like this, replacing the URLas appropriate:-```+```textUBUNTU_MIRROR http://us.archive.ubuntu.com/ubuntu/```@@ -944,14 +944,14 @@ If you need to use a proxy server to access the Internet, you willneed to specify the proxy settings before running `Vagrant up`.First, install the Vagrant plugin `vagrant-proxyconf`:-```+```bashvagrant plugin install vagrant-proxyconf```Then create `~/.zulip-vagrant-config` and add the following lines toit (with the appropriate values in it for your proxy):-```+```textHTTP_PROXY http://proxy_host:portHTTPS_PROXY http://proxy_host:portNO_PROXY localhost,127.0.0.1,.example.com,.zulipdev.com@@ -960,7 +960,7 @@ NO_PROXY localhost,127.0.0.1,.example.com,.zulipdev.comFor proxies that require authentication, the config will be a bit morecomplex, e.g.:-```+```textHTTP_PROXY http://userName:[email protected]:8080HTTPS_PROXY http://userName:[email protected]:8080NO_PROXY localhost,127.0.0.1,.example.com,.zulipdev.com@@ -985,7 +985,7 @@ then do a `vagrant reload`.You can also change the port on the host machine that Vagrant uses byadding to your `~/.zulip-vagrant-config` file. E.g. if you set:-```+```textHOST_PORT 9971```@@ -996,7 +996,7 @@ If you'd like to be able to connect to your development environment from othermachines than the VM host, you can manually set the host IP address in the'~/.zulip-vagrant-config' file as well. For example, if you set:-```+```textHOST_IP_ADDR 0.0.0.0```@@ -1022,14 +1022,14 @@ more resources.To do so, create a `~/.zulip-vagrant-config` file containing thefollowing lines:-```+```textGUEST_CPUS <number of cpus>GUEST_MEMORY_MB <system memory (in MB)>```For example:-```+```textGUEST_CPUS 4GUEST_MEMORY_MB 8192```diff --git a/docs/development/test-install.md b/docs/development/test-install.mdindex 27bd782e985..8c904f1ca62 100644--- a/docs/development/test-install.md+++ b/docs/development/test-install.md@@ -17,7 +17,7 @@ RAM, in order to accommodate the VMs and the steps which build therelease assets.To begin, install the LXC toolchain:-```+```bashsudo apt-get install lxc lxc-utils```@@ -32,7 +32,7 @@ You only need to do this step once per time you work on a set ofchanges, to refresh the package that the installer uses. The installerdoesn't work cleanly out of a source checkout; it wants a releasecheckout, so we build a tarball of one of those first:-```+```bash./tools/build-release-tarball test-installer```@@ -46,7 +46,7 @@ directory. The test installer needs the release directory to be named`zulip-server`, so we rename it and move it appropriately. In thefirst line, you'll need to substitute the actual path that you got forthe tarball, above:-```+```bashtar xzf /tmp/tmp.fepqqNBWxp/zulip-server-test-installer.tar.gzmkdir zulip-test-installermv zulip-server-test-installer zulip-test-installer/zulip-server@@ -65,7 +65,7 @@ into the installer.For example, to test an install onto Ubuntu 20.04 "Focal", we mightcall:-```+```bashsudo ./tools/test-install/install \-r focal \./zulip-test-installer/ \@@ -82,7 +82,7 @@ take a while.Regardless of if the install succeeds or fails, it will stay runningso you can inspect it. You can see all of the containers which arerunning, and their randomly-generated names, by running:-```+```bashsudo lxc-ls -f```@@ -90,7 +90,7 @@ sudo lxc-ls -fAfter using `lxc-ls` to list containers, you can choose one of themand connect to its terminal:-```+```bashsudo lxc-attach --clear-env -n zulip-install-focal-PUvff```@@ -98,12 +98,12 @@ sudo lxc-attach --clear-env -n zulip-install-focal-PUvffTo destroy all containers (but leave the base containers, which speedup the initial install):-```+```bashsudo ./tools/test-install/destroy-all -f```To destroy just one container:-```+```bashsudo lxc-destroy -f -n zulip-install-focal-PUvff```@@ -115,7 +115,7 @@ Iterate on the installer by making changes to your source tree,copying them into the release directory, and re-running the installer,which will start up a new container. Here, we update just the`scripts` and `puppet` directories of the release directory:-```+```bashrsync -az scripts puppet zulip-test-installer/zulip-server/sudo ./tools/test-install/install \@@ -124,4 +124,3 @@ sudo ./tools/test-install/install \--hostname=zulip.example.net \```-diff --git a/docs/documentation/api.md b/docs/documentation/api.mdindex b9f48bcd242..50ef087a782 100644--- a/docs/documentation/api.md+++ b/docs/documentation/api.md@@ -106,7 +106,7 @@ defined using a special Markdown extension(`zerver/openapi/markdown_extension.py`). To use this extension, onewrites a Markdown file block that looks something like this:-```+```md{start_tabs}{tab|python}@@ -184,7 +184,7 @@ an API endpoint supports. You'll see this in files likedirective (implemented in`zerver/lib/markdown/api_arguments_table_generator.py`):-```+```md{generate_api_arguments_table|zulip.yaml|/messages/render:post}```@@ -204,7 +204,7 @@ section, this part should be fairly trivial.You can use the following Markdown directive to render all the fixturesdefined in the OpenAPI `zulip.yaml` for a given endpoint-```+```md{generate_code_example|/messages/render:post|fixture}```diff --git a/docs/documentation/integrations.md b/docs/documentation/integrations.mdindex db1d693f4b0..d9f72bcbd36 100644--- a/docs/documentation/integrations.md+++ b/docs/documentation/integrations.md@@ -46,7 +46,7 @@ Usually, this involves a few steps:If your new integration is an incoming webhook integration, you can generatethe screenshot using `tools/generate-integration-docs-screenshot`:- ```sh+ ```bash./tools/generate-integration-docs-screenshot --integration integrationname```@@ -136,7 +136,7 @@ Here are a few common macros used to document Zulip's integrations:* `{!webhook-url-with-bot-email.md!}` - Used in certain non-webhook integrationsto generate URLs of the form:- ```+ ```texthttps://bot_email:[email protected]/api/v1/external/beanstalk```diff --git a/docs/documentation/openapi.md b/docs/documentation/openapi.mdindex a50ffa3a4af..701b1e15de3 100644--- a/docs/documentation/openapi.md+++ b/docs/documentation/openapi.md@@ -40,7 +40,7 @@ types of authentication, and configure other settings. Once defined,information in this section rarely changes.For example, the `swagger` and `info` objects look like this:-```+```yaml# Basic Swagger UI infoopenapi: 3.0.1info:@@ -79,7 +79,7 @@ expects a GET request with oneBasic authentication, and returns a JSON response containing `msg`,`result`, and `presence` values.-```+```yaml/users/{user}/presence:get:description: Get presence data for another user.@@ -119,7 +119,7 @@ contains schemas referenced by other objects. For example,contains three required parameters. Two are strings, and one is aninteger.-```+```yamlMessageResponse:type: objectrequired:@@ -183,7 +183,7 @@ correct.### Examples:-```+```yamlDescription: |This description has multiple lines.Sometimes descriptions can go on fordiff --git a/docs/documentation/overview.md b/docs/documentation/overview.mdindex 39bc3b7ed8b..9fd89ae9ae9 100644--- a/docs/documentation/overview.md+++ b/docs/documentation/overview.md@@ -43,7 +43,7 @@ your changes), the dependencies are automatically installed as part ofZulip development environment provisioning, and you can build thedocumentation using:-```+```bash./tools/build-docs```diff --git a/docs/documentation/user.md b/docs/documentation/user.mdindex 21471e6b203..d021cf3afdd 100644--- a/docs/documentation/user.md+++ b/docs/documentation/user.md@@ -210,7 +210,7 @@ instructions. For instance, it may address a common problem users mayencounter while following the instructions, or point to an option for powerusers.-```+```md!!! tip ""If you've forgotten your password, see the[Change your password](/help/change-your-password) page for@@ -220,7 +220,7 @@ users.A **warning** is a note on what happens when there is some kind of problem.Tips are more common than warnings.-```+```md!!! warn ""**Note:** If you attempt to input a nonexistent stream name, an errormessage will appear.@@ -237,14 +237,16 @@ design to easily show the instructions for different[platforms](https://zulip.com/help/logging-out) in user docs,languages in API docs, etc. To create a tab switcher, write:- {start_tabs}- {tab|desktop-web}- # First tab's content- {tab|ios}- # Second tab's content- {tab|android}- # Third tab's content- {end_tabs}+```md+{start_tabs}+{tab|desktop-web}+# First tab's content+{tab|ios}+# Second tab's content+{tab|android}+# Third tab's content+{end_tabs}+```The tab identifiers (e.g. `desktop-web` above) and their mappings tothe tabs' labels are declared indiff --git a/docs/git/cloning.md b/docs/git/cloning.mdindex 0dd1687fd5b..b464c45e670 100644--- a/docs/git/cloning.md+++ b/docs/git/cloning.md@@ -20,7 +20,7 @@ the main server app, this is [zulip/zulip][github-zulip-zulip].Next, clone your fork to your local machine:-```+```console$ git clone --config pull.rebase https://github.com/YOUR_USERNAME/zulip.gitCloning into 'zulip'remote: Counting objects: 86768, done.@@ -56,7 +56,7 @@ your fork.First, show the currently configured remote repository:-```+```console$ git remote -vorigin [email protected]:YOUR_USERNAME/zulip.git (fetch)origin [email protected]:YOUR_USERNAME/zulip.git (push)@@ -68,7 +68,7 @@ have the upstream remote repository configured. For example, when you clonethe remote repository `zulip` and you see the following output from `git remote-v`:-```+```consoleorigin [email protected]:YOUR_USERNAME/zulip.git (fetch)origin [email protected]:YOUR_USERNAME/zulip.git (push)zulip https://github.com/zulip/zulip.git (fetch)@@ -78,13 +78,13 @@ zulip https://github.com/zulip/zulip.git (push)If your client hasn't automatically configured a remote for zulip/zulip, you'llneed to with:-```+```console$ git remote add -f upstream https://github.com/zulip/zulip.git```Finally, confirm that the new remote repository, upstream, has been configured:-```+```console$ git remote -vorigin [email protected]:YOUR_USERNAME/zulip.git (fetch)origin [email protected]:YOUR_USERNAME/zulip.git (push)diff --git a/docs/git/collaborate.md b/docs/git/collaborate.mdindex 4c00ec1d880..4d2ec0a1003 100644--- a/docs/git/collaborate.md+++ b/docs/git/collaborate.md@@ -6,7 +6,7 @@ What happens when you would like to collaborate with another contributor andthey have work-in-progress on their own fork of Zulip? No problem! Just addtheir fork as a remote and pull their changes.-```+```console$ git remote add <username> https://github.com/<username>/zulip.git$ git fetch <username>```@@ -15,12 +15,12 @@ Now you can check out their branch just like you would any other. You can namethe branch anything you want, but using both the username and branch name willhelp you keep things organized.-```+```console$ git checkout -b <username>/<branchname>```You can choose to rename the branch if you prefer:-```+```bashgit checkout -b <custombranchname> <username>/<branchname>```@@ -34,13 +34,13 @@ specific to GitHub rather than Git.First, fetch and create a branch for the pull request, replacing *ID* and*BRANCHNAME* with the ID of the pull request and your desired branch name:-```+```console$ git fetch upstream pull/ID/head:BRANCHNAME```Now switch to the branch:-```+```console$ git checkout BRANCHNAME```@@ -48,7 +48,7 @@ Now you work on this branch as you would any other.Note: you can use the scripts provided in the tools/ directory to fetch pullrequests. You can read more about what they do [here][tools-PR].-```+```bashtools/fetch-rebase-pull-request <PR-number>tools/fetch-pull-request <PR-number>```diff --git a/docs/git/pull-requests.md b/docs/git/pull-requests.mdindex d50b6cb9f43..2c04dfe47ad 100644--- a/docs/git/pull-requests.md+++ b/docs/git/pull-requests.md@@ -46,7 +46,7 @@ fork up to date][keep-up-to-date] for details.Here's an example (you would replace *issue-123* with the name of your feature branch):-```+```console$ git checkout issue-123Switched to branch 'issue-123'@@ -68,7 +68,7 @@ Applying: troubleshooting tip about provisioningOnce you've updated your local feature branch, push the changes to GitHub:-```+```console$ git push origin issue-123Counting objects: 6, done.Delta compression using up to 4 threads.@@ -83,7 +83,7 @@ To [email protected]:christi3k/zulip.gitIf your push is rejected with error **failed to push some refs** then you needto prefix the name of your branch with a `+`:-```+```console$ git push origin +issue-123Counting objects: 6, done.Delta compression using up to 4 threads.diff --git a/docs/git/reviewing.md b/docs/git/reviewing.mdindex 6c102e24e7e..def8033c6b1 100644--- a/docs/git/reviewing.md+++ b/docs/git/reviewing.md@@ -8,20 +8,20 @@ on reviewing changes by other contributors.Display changes between index and working tree (what is not yet staged for commit):-```+```console$ git diff```Display changes between index and last commit (what you have staged for commit):-```+```console$ git diff --cached```Display changes in working tree since last commit (changes that are staged aswell as ones that are not):-```+```console$ git diff HEAD```@@ -31,13 +31,13 @@ Use any git-ref to compare changes between two commits on the current branch.Display changes between commit before last and last commit:-```+```console$ git diff HEAD^ HEAD```Display changes between two commits using their hashes:-```+```console$ git diff e2f404c 7977169```@@ -45,19 +45,19 @@ $ git diff e2f404c 7977169Display changes between tip of topic branch and tip of master branch:-```+```console$ git diff topic master```Display changes that have occurred on master branch since topic branch was created:-```+```console$ git diff topic...master```Display changes you've committed so far since creating a branch from upstream/master:-```+```console$ git diff upstream/master...HEAD```diff --git a/docs/git/troubleshooting.md b/docs/git/troubleshooting.mdindex 4cfcbe7ea61..99d677724af 100644--- a/docs/git/troubleshooting.md+++ b/docs/git/troubleshooting.md@@ -26,7 +26,7 @@ A merge commit is usually created when you've run `git pull` or `git merge`.You'll know you're creating a merge commit if you're prompted for a commitmessage and the default is something like this:-```+```textMerge branch 'master' of https://github.com/zulip/zulip# Please enter a commit message to explain why this merge is necessary,@@ -38,7 +38,7 @@ Merge branch 'master' of https://github.com/zulip/zulipAnd the first entry for `git log` will show something like:-```+```consolecommit e5f8211a565a5a5448b93e98ed56415255546f94Merge: 13bea0e e0c10edAuthor: Christie Koehler <[email protected]>@@ -52,7 +52,7 @@ Some graphical Git clients may also create merge commits.To undo a merge commit, first run `git reflog` to identify the commit you wantto roll back to:-```+```console$ git refloge5f8211 HEAD@{0}: pull upstream master: Merge made by the 'recursive' strategy.@@ -67,7 +67,7 @@ by `git pull` and `13bea0e HEAD@{1}:` is the last commit I made before runningOnce you'd identified the ref you want to revert to, you can do so with [gitreset][gitbook-reset]:-```+```console$ git reset --hard 13bea0eHEAD is now at 13bea0e test commit for docs.```@@ -86,7 +86,7 @@ just keep in mind that this changes as you run git commands.Now when you look at the output of `git reflog`, you should see that the tip of your branch points to yourlast commit `13bea0e` before the merge:-```+```console$ git reflog13bea0e HEAD@{2}: reset: moving to HEAD@{1}@@ -96,7 +96,7 @@ e5f8211 HEAD@{3}: pull upstream master: Merge made by the 'recursive' strategy.And the first entry `git log` shows is this:-```+```consolecommit 13bea0e40197b1670e927a9eb05aaf50df9e8277Author: Christie Koehler <[email protected]>Date: Mon Oct 10 13:25:38 2016 -0700@@ -114,14 +114,14 @@ with `git cherry-pick` ([docs][gitbook-git-cherry-pick]).For example, let's say you just committed "some work" and your `git log` lookslike this:-```+```console* 67aea58 (HEAD -> master) some work* 13bea0e test commit for docs.```You then mistakenly run `git reset --hard 13bea0e`:-```+```console$ git reset --hard 13bea0eHEAD is now at 13bea0e test commit for docs.@@ -133,7 +133,7 @@ And then realize you actually needed to keep commit 67aea58. First, use `gitreflog` to confirm that commit you want to restore and then run `gitcherry-pick <commit>`:-```+```console$ git reflog13bea0e HEAD@{0}: reset: moving to 13bea0e67aea58 HEAD@{1}: commit: some work@@ -159,7 +159,7 @@ change to a part of the file I also want to change. When I try to bring mybranch up to date with `git fetch` and then `git rebase upstream/master`, I seethe following:-```+```consoleFirst, rewinding head to replay your work on top of it...Applying: test change for docsUsing index info to reconstruct a base tree...@@ -181,7 +181,7 @@ after bringing in the new commits from upstream/master.Running `git status` also gives me some information:-```+```consolerebase in progress; onto 5ae56e6You are currently rebasing branch 'docs-test' on '5ae56e6'.(fix conflicts and then run "git rebase --continue")@@ -203,7 +203,7 @@ and `>>>>>>>`) markers to indicate where in files there are conflicts.Tip: You can see recent changes made to a file by running the followingcommands:-```+```bashgit fetch upstreamgit log -p upstream/master -- /path/to/file```@@ -214,7 +214,7 @@ you are rebasing.Once you've done that, save the file(s), stage them with `git add` and thencontinue the rebase with `git rebase --continue`:-```+```console$ git add README.md$ git rebase --continue@@ -240,7 +240,7 @@ where you committed them.So, before you stop working for the day, or before you switch computers, pushall of your commits to GitHub with `git push`:-```+```console$ git push origin <branchname>```@@ -253,7 +253,7 @@ But if you're switching to another computer on which you have already clonedZulip, you need to update your local Git database with new refs from yourGitHub fork. You do this with `git fetch`:-```+```console$ git fetch <usermame>```@@ -261,7 +261,7 @@ Ideally you should do this before you have made any commits on the same branchon the second computer. Then you can `git merge` on whichever branch you needto update:-```+```console$ git checkout <my-branch>Switched to branch '<my-branch>'diff --git a/docs/git/using.md b/docs/git/using.mdindex 9696b853035..f9b2fc56afa 100644--- a/docs/git/using.md+++ b/docs/git/using.md@@ -8,7 +8,7 @@ determine the currently checked out branch several ways.One way is with [git status][gitbook-git-status]:-```+```console$ git statusOn branch issue-demonothing to commit, working directory clean@@ -17,7 +17,7 @@ nothing to commit, working directory cleanAnother is with [git branch][gitbook-git-branch] which will display all localbranches, with a star next to the current branch:-```+```console$ git branch* issue-demomaster@@ -26,7 +26,7 @@ $ git branchTo see even more information about your branches, including remote branches,use `git branch -vva`:-```+```console$ git branch -vva* issue-123 517468b troubleshooting tip about provisioningmaster f0eaee6 [origin/master] bug: Fix traceback in get_missed_message_token_from_address().@@ -53,14 +53,14 @@ and then `git rebase`.First, [fetch][gitbook-fetch] changes from Zulip's upstream repository youconfigured in the step above:-```+```console$ git fetch upstream```Next, check out your `master` branch and [rebase][gitbook-git-rebase] it on topof `upstream/master`:-```+```console$ git checkout masterSwitched to branch 'master'@@ -74,7 +74,7 @@ history clean and readable.When you're ready, [push your changes][github-help-push] to your remote fork.Make sure you're in branch `master` and then run `git push`:-```+```console$ git checkout master$ git push origin master```@@ -83,7 +83,7 @@ You can keep any branch up to date using this method. If you're working on afeature branch (see next section), which we recommend, you would change thecommand slightly, using the name of your `feature-branch` rather than `master`:-```+```console$ git checkout feature-branchSwitched to branch 'feature-branch'@@ -105,7 +105,7 @@ how][zulip-git-guide-up-to-date]).Next, from your master branch, create a new tracking branch, providing adescriptive name for your feature branch:-```+```console$ git checkout masterSwitched to branch 'master'@@ -116,7 +116,7 @@ Switched to a new branch 'issue-1755-fail2ban'Alternatively, you can create a new branch explicitly based off`upstream/master`:-```+```console$ git checkout -b issue-1755-fail2ban upstream/masterSwitched to a new branch 'issue-1755-fail2ban'```@@ -146,7 +146,7 @@ staged, use `git status`.If you have no changes in the working directory, you'll see something likethis:-```+```console$ git statusOn branch issue-123nothing to commit, working directory clean@@ -154,7 +154,7 @@ nothing to commit, working directory cleanIf you have unstaged changes, you'll see something like this:-```+```consoleOn branch issue-123Untracked files:(use "git add <file>..." to include in what will be committed)@@ -173,7 +173,7 @@ add` is all about staging the changes you want to commit, you use it to addContinuing our example from above, after we run `git add newfile.py`, we'll seethe following from `git status`:-```+```consoleOn branch issue-123Changes to be committed:(use "git reset HEAD <file>..." to unstage)@@ -193,7 +193,7 @@ You can also stage changes using your graphical Git client.If you stage a file, you can undo it with `git reset HEAD <filename>`. Here'san example where we stage a file `test3.txt` and then unstage it:-```+```console$ git add test3.txtOn branch issue-1234Changes to be committed:@@ -222,7 +222,7 @@ stage the file for deletion and leave it in your working directory.To stage a file for deletion and **remove** it from your working directory, use`git rm <filename>`:-```+```console$ git rm test.txtrm 'test.txt'@@ -240,7 +240,7 @@ ls: No such file or directoryTo stage a file for deletion and **keep** it in your working directory, use`git rm --cached <filename>`:-```+```console$ git rm --cached test2.txtrm 'test2.txt'@@ -258,7 +258,7 @@ test2.txtIf you stage a file for deletion with the `--cached` option, and haven't yetrun `git commit`, you can undo it with `git reset HEAD <filename>`:-```+```console$ git reset HEAD test2.txt```@@ -273,7 +273,7 @@ with `git commit -m "My commit message."` to include a commit message.Here's an example of committing with the `-m` for a one-line commit message:-```+```console$ git commit -m "Add a test commit for docs."[issue-123 173e17a] Add a test commit for docs.1 file changed, 1 insertion(+)@@ -295,7 +295,7 @@ messages][zulip-rtd-commit-messages] for details.Here's an example of a longer commit message that will be used for a pull request:-```+```textIntegrate Fail2Ban.Updates Zulip logging to put an unambiguous entry into the logs such@@ -337,7 +337,7 @@ machine and allows others to follow your progress. It also allows you toPushing to a feature branch is just like pushing to master:-```+```console$ git push origin <branch-name>Counting objects: 6, done.Delta compression using up to 4 threads.@@ -367,7 +367,7 @@ your commit history be able to clearly understand your progression of work?On the command line, you can use the `git log` command to display an easy toread list of your commits:-```+```console$ git log --all --graph --oneline --decorate* 4f8d75d (HEAD -> 1754-docs-add-git-workflow) docs: Add details about configuring Travis CI.@@ -404,7 +404,7 @@ Any time you alter history for commits you have already pushed to GitHub,you'll need to prefix the name of your branch with a `+`. Without this, yourupdates will be rejected with a message such as:-```+```console$ git push origin 1754-docs-add-git-workflowTo [email protected]:christi3k/zulip.git! [rejected] 1754-docs-add-git-workflow -> 1754-docs-add-git-workflow (non-fast-forward)@@ -418,7 +418,7 @@ hint: See the 'Note about fast-forwards' in 'git push --help' for details.Re-running the command with `+<branch>` allows the push to continue byre-writing the history for the remote repository:-```+```console$ git push origin +1754-docs-add-git-workflowCounting objects: 12, done.Delta compression using up to 4 threads.diff --git a/docs/git/zulip-tools.md b/docs/git/zulip-tools.mdindex da3a1568959..dcf6ca58c6d 100644--- a/docs/git/zulip-tools.md+++ b/docs/git/zulip-tools.md@@ -16,7 +16,7 @@ notices or warnings it displays.It's simple to use. Make sure you're in the clone of zulip and run the following:-```+```console$ ./tools/setup-git-repo```@@ -24,7 +24,7 @@ The script doesn't produce any output if successful. To check that the hook hasbeen installed, print a directory listing for `.git/hooks` and you should seesomething similar to:-```+```console$ ls -l .git/hookspre-commit -> ../../tools/pre-commit```@@ -47,7 +47,7 @@ First, make sure you are working in a branch you want to move (in thisexample, we'll use the local `master` branch). Then run the scriptwith the ID number of the pull request as the first argument.-```+```console$ git checkout masterSwitched to branch 'master'Your branch is up-to-date with 'origin/master'.@@ -74,7 +74,7 @@ changes from upstream/master with `git rebase`.Run the script with the ID number of the pull request as the first argument.-```+```console$ tools/fetch-rebase-pull-request 1913+ request_id=1913+ git fetch upstream pull/1913/head@@ -101,7 +101,7 @@ exactly the same repository state as the commit author had.Run the script with the ID number of the pull request as the first argument.-```+```console$ tools/fetch-pull-request 5156+ git diff-index --quiet HEAD+ request_id=5156@@ -155,7 +155,7 @@ arguments for default behavior. Since removing review branches can inadvertentlyfeature branches whose names are like `review-*`, it is not done by default. Touse it, run `tools/clean-branches --reviews`.-```+```console$ tools/clean-branches --reviewsDeleting local branch review-original-5156 (was 5a1e982)```@@ -167,7 +167,7 @@ regenerate the file. *Important* don't delete the yarn.lock file. Check out thelatest one from origin/master so that yarn knows the previous asset versions.Run the following commands-```+```bashgit checkout origin/master -- yarn.lockyarn installgit add yarn.lockdiff --git a/docs/overview/architecture-overview.md b/docs/overview/architecture-overview.mdindex 3a593635f77..f3d17ecfda1 100644--- a/docs/overview/architecture-overview.md+++ b/docs/overview/architecture-overview.md@@ -181,8 +181,10 @@ Redis is configured in `zulip/puppet/zulip/files/redis` and it's apretty standard configuration except for the last line, which turns offpersistence:- # Zulip-specific configuration: disable saving to disk.- save ""+```text+# Zulip-specific configuration: disable saving to disk.+save ""+```People often wonder if we could replace memcached with Redis (orreplace RabbitMQ with Redis, with some loss of functionality).diff --git a/docs/overview/changelog.md b/docs/overview/changelog.mdindex 941babed3ff..0d879e58f4b 100644--- a/docs/overview/changelog.md+++ b/docs/overview/changelog.md@@ -526,7 +526,7 @@ log][commit-log] for an up-to-date list of raw changes.that will fix this bug. The new migration will fail if any suchduplicate accounts already exist; you can check whether this willhappen be running the following in a [management shell][manage-shell]:- ```+ ```pythonfrom django.db.models.functions import LowerUserProfile.objects.all().annotate(email_lower=Lower("delivery_email")).values('realm_id', 'email_lower').annotate(Count('id')).filter(id__count__gte=2)diff --git a/docs/production/authentication-methods.md b/docs/production/authentication-methods.mdindex f6d6902a158..e2688924c90 100644--- a/docs/production/authentication-methods.md+++ b/docs/production/authentication-methods.md@@ -96,7 +96,7 @@ In either configuration, you will need to do the following:* Set `AUTH_LDAP_REVERSE_EMAIL_SEARCH` to a query that will findan LDAP user given their email address (i.e. a search by`LDAP_EMAIL_ATTR`). For example:- ```+ ```pythonAUTH_LDAP_REVERSE_EMAIL_SEARCH = LDAPSearch("ou=users,dc=example,dc=com",ldap.SCOPE_SUBTREE, "(mail=%(email)s)")```@@ -105,7 +105,7 @@ In either configuration, you will need to do the following:You can quickly test whether your configuration works by running:-```+```bash/home/zulip/deployments/current/manage.py query_ldap username```@@ -117,7 +117,7 @@ email address, if it isn't the same as the "Zulip username").of the following configurations:* To access by Active Directory username:- ```+ ```pythonAUTH_LDAP_USER_SEARCH = LDAPSearch("ou=users,dc=example,dc=com",ldap.SCOPE_SUBTREE, "(sAMAccountName=%(user)s)")AUTH_LDAP_REVERSE_EMAIL_SEARCH = LDAPSearch("ou=users,dc=example,dc=com",@@ -126,7 +126,7 @@ of the following configurations:```* To access by Active Directory email address:- ```+ ```pythonAUTH_LDAP_USER_SEARCH = LDAPSearch("ou=users,dc=example,dc=com",ldap.SCOPE_SUBTREE, "(mail=%(user)s)")AUTH_LDAP_REVERSE_EMAIL_SEARCH = LDAPSearch("ou=users,dc=example,dc=com",@@ -155,7 +155,7 @@ Zulip can automatically synchronize data declared in`AUTH_LDAP_USER_ATTR_MAP` from LDAP into Zulip, via the followingmanagement command:-```+```bash/home/zulip/deployments/current/manage.py sync_ldap_user_data```@@ -262,7 +262,7 @@ the fields that would be useful to sync from your LDAP databases.### Multiple LDAP searchesTo do the union of multiple LDAP searches, use `LDAPSearchUnion`. For example:-```+```pythonAUTH_LDAP_USER_SEARCH = LDAPSearchUnion(LDAPSearch("ou=users,dc=example,dc=com", ldap.SCOPE_SUBTREE, "(uid=%(user)s)"),LDAPSearch("ou=otherusers,dc=example,dc=com", ldap.SCOPE_SUBTREE, "(uid=%(user)s)"),@@ -292,7 +292,7 @@ For the root subdomain, `www` in the list will work, or any other ofFor example, with `org_membership` set to `department`, a user withthe following attributes will have access to the root and `engineering` subdomains:-```+```text...department: engineeringdepartment: www@@ -419,12 +419,12 @@ it as follows:trust, which consists of multiple certificates. The private key cannot be encryptedwith a password, as then Zulip will not be able to load it. An example pair can begenerated using:- ```+ ```bashopenssl req -x509 -newkey rsa:2056 -keyout zulip-private-key.key -out zulip-cert.crt -days 365 -nodes```4. Set the proper permissions on these files and directories:- ```+ ```bashchown -R zulip.zulip /etc/zulip/saml/find /etc/zulip/saml/ -type f -exec chmod 644 -- {} +chmod 640 /etc/zulip/saml/zulip-private-key.key@@ -507,7 +507,7 @@ For example, with `attr_org_membership` set to `member`, a user withthe following attribute in their `AttributeStatement` will have accessto the root and `engineering` subdomains:-```+```xml<saml2:Attribute Name="member" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"><saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">www@@ -540,7 +540,7 @@ straightforward way to deploy that SSO solution with Zulip.2. Edit `/etc/zulip/zulip.conf` and change the `puppet_classes` line to read:- ```+ ```inipuppet_classes = zulip::profile::standalone, zulip::apache_sso```@@ -558,7 +558,7 @@ straightforward way to deploy that SSO solution with Zulip.using the `htpasswd` example configuration and demonstrate thatworking end-to-end, before returning later to configure your SSOsolution. You can do that with the following steps:- ```+ ```bash/home/zulip/deployments/current/scripts/restart-servercd /etc/apache2/sites-available/cp zulip-sso.example zulip-sso.conf@@ -652,7 +652,7 @@ domain for your server).`/etc/zulip/apple-auth-key.p8`. Be sure to setpermissions correctly:- ```+ ```bashchown zulip:zulip /etc/zulip/apple-auth-key.p8chmod 640 /etc/zulip/apple-auth-key.p8```diff --git a/docs/production/deployment.md b/docs/production/deployment.mdindex e1dcc394819..e2ed7d37cd8 100644--- a/docs/production/deployment.md+++ b/docs/production/deployment.md@@ -11,7 +11,7 @@ something more complicated. This page documents the options for doing so.To install a development version of Zulip from Git, just clone the Gitrepository from GitHub:-```+```bash# First, install Git if you don't have it installed alreadysudo apt install gitgit clone https://github.com/zulip/zulip.git zulip-server-git@@ -103,7 +103,7 @@ configuration to be completely modular.For example, to install a Zulip Redis server on a machine, you can runthe following after unpacking a Zulip production release tarball:-```+```bashenv PUPPET_CLASSES=zulip::profile::redis ./scripts/setup/install```@@ -136,7 +136,7 @@ Follow the [standard instructions](../production/install.md), with onechange. When running the installer, pass the `--no-init-db`flag, e.g.:-```+```bashsudo -s # If not already root./zulip-server-*/scripts/setup/install --certbot \--email=YOUR_EMAIL --hostname=YOUR_HOSTNAME \@@ -147,7 +147,7 @@ The script also installs and starts PostgreSQL on the server bydefault. We don't need it, so run the following command tostop and disable the local PostgreSQL server.-```+```bashsudo service postgresql stopsudo update-rc.d postgresql disable```@@ -184,13 +184,13 @@ If you're using password authentication, you should specify thepassword of the `zulip` user in /etc/zulip/zulip-secrets.conf asfollows:-```+```inipostgres_password = abcd1234```Now complete the installation by running the following commands.-```+```bash# Ask Zulip installer to initialize the PostgreSQL database.su zulip -c '/home/zulip/deployments/current/scripts/setup/initialize-database'@@ -208,7 +208,7 @@ configure that as follows:with `/home/zulip/deployments/current/scripts/restart-server`.1. Add the following block to `/etc/zulip/zulip.conf`:- ```+ ```ini[application_server]nginx_listen_port = 12345```@@ -236,7 +236,7 @@ To use Smokescreen:1. Add `, zulip::profile::smokescreen` to the list of `puppet_classes`in `/etc/zulip/zulip.conf`. A typical value after this change is:- ```+ ```inipuppet_classes = zulip::profile::standalone, zulip::profile::smokescreen```@@ -248,7 +248,7 @@ To use Smokescreen:1. Add the following block to `/etc/zulip/zulip.conf`, substituting inyour proxy's hostname/IP and port:- ```+ ```ini[http_proxy]host = 127.0.0.1port = 4750@@ -297,7 +297,7 @@ HTTP as follows:1. Add the following block to `/etc/zulip/zulip.conf`:- ```+ ```ini[application_server]http_only = true```@@ -321,7 +321,7 @@ For `nginx` configuration, there's two things you need to set up:`/etc/nginx/sites-available`) for the Zulip app. The followingexample is a good starting point:-```+```nginxserver {listen 443 ssl http2;listen [::]:443 ssl http2;@@ -358,7 +358,7 @@ make the following changes in two configuration files.1. Follow the instructions for [Configure Zulip to allow HTTP](#configuring-zulip-to-allow-http).2. Add the following to `/etc/zulip/settings.py`:- ```+ ```pythonEXTERNAL_HOST = 'zulip.example.com'ALLOWED_HOSTS = ['zulip.example.com', '127.0.0.1']USE_X_FORWARDED_HOST = True@@ -374,7 +374,7 @@ make the following changes in two configuration files.and then run `a2ensite zulip.example.com && systemctl reloadapache2`):- ```+ ```apache<VirtualHost *:80>ServerName zulip.example.comRewriteEngine On@@ -415,7 +415,7 @@ make the following changes in two configuration files.If you want to use HAProxy with Zulip, this `backend` config is a goodplace to start.-```+```textbackend zulipmode httpbalance leastconndiff --git a/docs/production/email-gateway.md b/docs/production/email-gateway.mdindex 71b2453edd0..5b983d08873 100644--- a/docs/production/email-gateway.md+++ b/docs/production/email-gateway.md@@ -56,7 +56,7 @@ using an [HTTP reverse proxy][reverse-proxy]).configuring email for `emaildomain.example.com` to be processed by`hostname.example.com`. You can check your work using this command:- ```+ ```console$ dig +short emaildomain.example.com -t MX1 hostname.example.com```@@ -65,7 +65,7 @@ using an [HTTP reverse proxy][reverse-proxy]).1. Add `, zulip::postfix_localmail` to `puppet_classes` in`/etc/zulip/zulip.conf`. A typical value after this change is:- ```+ ```inipuppet_classes = zulip::profile::standalone, zulip::postfix_localmail```@@ -73,7 +73,7 @@ using an [HTTP reverse proxy][reverse-proxy]).`emaildomain.example.com`, add a section to `/etc/zulip/zulip.conf`on your Zulip server like this:- ```+ ```ini[postfix]mailname = emaildomain.example.com```@@ -116,7 +116,7 @@ Congratulations! The integration should be fully operational.* Password in `/etc/zulip/zulip-secrets.conf` as `email_gateway_password`.1. Install a cron job to poll the inbox every minute for new messages:- ```+ ```bashcd /home/zulip/deployments/current/sudo cp puppet/zulip/files/cron.d/email-mirror /etc/cron.d/```diff --git a/docs/production/email.md b/docs/production/email.mdindex 19b57343a28..f919882906a 100644--- a/docs/production/email.md+++ b/docs/production/email.md@@ -78,7 +78,7 @@ configuration on the system that forwards email sent locally into yourcorporate email system), you will likely need to use something likethese setting values:-```+```pythonEMAIL_HOST = 'localhost'EMAIL_PORT = 25EMAIL_USE_TLS = False@@ -122,7 +122,7 @@ can log them to a file instead.To do so, add these lines to `/etc/zulip/settings.py`:-```+```pythonEMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'EMAIL_FILE_PATH = '/var/log/zulip/emails'```@@ -137,7 +137,7 @@ later set up a real SMTP provider!You can quickly test your outgoing email configuration using:-```+```bashsu zulip -c '/home/zulip/deployments/current/manage.py send_test_email [email protected]'```diff --git a/docs/production/expensive-migrations.md b/docs/production/expensive-migrations.mdindex e6226990ef3..4b08de229e8 100644--- a/docs/production/expensive-migrations.md+++ b/docs/production/expensive-migrations.md@@ -19,42 +19,46 @@ can run them manually before starting the upgrade:PostgreSQL database.3. In the PostgreSQL shell, run the following commands:- CREATE INDEX CONCURRENTLY- zerver_usermessage_is_private_message_id- ON zerver_usermessage (user_profile_id, message_id)- WHERE (flags & 2048) != 0;+ ```postgresql+ CREATE INDEX CONCURRENTLY+ zerver_usermessage_is_private_message_id+ ON zerver_usermessage (user_profile_id, message_id)+ WHERE (flags & 2048) != 0;- CREATE INDEX CONCURRENTLY- zerver_usermessage_active_mobile_push_notification_id- ON zerver_usermessage (user_profile_id, message_id)- WHERE (flags & 4096) != 0;+ CREATE INDEX CONCURRENTLY+ zerver_usermessage_active_mobile_push_notification_id+ ON zerver_usermessage (user_profile_id, message_id)+ WHERE (flags & 4096) != 0;+ ```-(These first migrations are the only new ones in Zulip 1.9).+ (These first migrations are the only new ones in Zulip 1.9).- CREATE INDEX CONCURRENTLY- zerver_usermessage_mentioned_message_id- ON zerver_usermessage (user_profile_id, message_id)- WHERE (flags & 8) != 0;+ ```postgresql+ CREATE INDEX CONCURRENTLY+ zerver_usermessage_mentioned_message_id+ ON zerver_usermessage (user_profile_id, message_id)+ WHERE (flags & 8) != 0;- CREATE INDEX CONCURRENTLY- zerver_usermessage_starred_message_id- ON zerver_usermessage (user_profile_id, message_id)- WHERE (flags & 2) != 0;+ CREATE INDEX CONCURRENTLY+ zerver_usermessage_starred_message_id+ ON zerver_usermessage (user_profile_id, message_id)+ WHERE (flags & 2) != 0;- CREATE INDEX CONCURRENTLY- zerver_usermessage_has_alert_word_message_id- ON zerver_usermessage (user_profile_id, message_id)- WHERE (flags & 512) != 0;+ CREATE INDEX CONCURRENTLY+ zerver_usermessage_has_alert_word_message_id+ ON zerver_usermessage (user_profile_id, message_id)+ WHERE (flags & 512) != 0;- CREATE INDEX CONCURRENTLY- zerver_usermessage_wildcard_mentioned_message_id- ON zerver_usermessage (user_profile_id, message_id)- WHERE (flags & 8) != 0 OR (flags & 16) != 0;+ CREATE INDEX CONCURRENTLY+ zerver_usermessage_wildcard_mentioned_message_id+ ON zerver_usermessage (user_profile_id, message_id)+ WHERE (flags & 8) != 0 OR (flags & 16) != 0;- CREATE INDEX CONCURRENTLY- zerver_usermessage_unread_message_id- ON zerver_usermessage (user_profile_id, message_id)- WHERE (flags & 1) = 0;+ CREATE INDEX CONCURRENTLY+ zerver_usermessage_unread_message_id+ ON zerver_usermessage (user_profile_id, message_id)+ WHERE (flags & 1) = 0;+ ```These will take some time to run, during which the server willcontinue to serve user traffic as usual with no disruption. Once theydiff --git a/docs/production/export-and-import.md b/docs/production/export-and-import.mdindex 436e53ef711..4c31e6bc293 100644--- a/docs/production/export-and-import.md+++ b/docs/production/export-and-import.md@@ -57,7 +57,7 @@ service (or back):The Zulip server has a built-in backup tool:-```+```bash# As the zulip user/home/zulip/deployments/current/manage.py backup# Or as root@@ -84,7 +84,7 @@ First, [install a new Zulip server through Step 3][install-server]with the same version of both the base OS and Zulip from your previousinstallation. Then, run as root:-```+```bash/home/zulip/deployments/current/scripts/setup/restore-backup /path/to/backup```@@ -113,7 +113,7 @@ tarball: `postgres-version`, `os-version`, and `zulip-version`. Thefollowing command may be useful for viewing these files withoutextracting the entire archive.-```+```bashtar -Oaxf /path/to/archive/zulip-backup-rest.tar.gz zulip-backup/zulip-version```@@ -167,7 +167,7 @@ daily incremental backups usingstoring the backups, edit `/etc/zulip/zulip-secrets.conf` on thePostgreSQL server to add:- ```+ ```inis3_backups_key = # aws public keys3_backups_secret_key = # aws secret keys3_backups_bucket = # name of S3 backup@@ -280,7 +280,7 @@ of the lines for the appropriate option.Log in to a shell on your Zulip server as the `zulip` user. Run thefollowing commands:-```+```bashcd /home/zulip/deployments/current# ./scripts/stop-server# export DEACTIVATE_FLAG="--deactivate" # Deactivates the organization@@ -307,7 +307,7 @@ archive of all the organization's uploaded files.master][upgrade-zulip-from-git], since we run run master onZulip Cloud:- ```+ ```bash/home/zulip/deployments/current/scripts/upgrade-zulip-from-git master```@@ -364,7 +364,7 @@ about doing so:following commands, replacing the filename with the path to your dataexport tarball:-```+```bashcd ~tar -xf /path/to/export/file/zulip-export-zcmpxfm6.tar.gzcd /home/zulip/deployments/current@@ -386,7 +386,7 @@ custom subdomain, e.g. if you already have an existing organization on theroot domain. Replace the last three lines above with the following, after replacing`<subdomain>` with the desired subdomain.-```+```bash./manage.py import <subdomain> ~/zulip-export-zcmpxfm6./manage.py reactivate_realm -r <subdomain> # Reactivates the organization```@@ -403,12 +403,12 @@ You can use the `./manage.py send_password_reset_email` command tosend password reset emails to your users. Werecommend starting with sending one to yourself for testing:-```+```bash./manage.py send_password_reset_email -u [email protected]```and then once you're ready, you can email them to everyone using e.g.-```+```bash./manage.py send_password_reset_email -r '' --all-users```@@ -426,7 +426,7 @@ organization using the following procedure:with the subdomain if [you are hosting the organization on asubdomain](../production/multiple-organizations.md):-```+```pythonrealm = Realm.objects.get(string_id="")realm.delete()```@@ -434,7 +434,7 @@ realm.delete()The output contains details on the objects deleted from the database.Now, exit the management shell and run this to clear Zulip's cache:-```+```bash/home/zulip/deployments/current/scripts/setup/flush-memcached```@@ -444,7 +444,7 @@ can additionally delete all file uploads, avatars, and custom emoji ona Zulip server (across **all organizations**) with the followingcommand:-```+```bashrm -rf /home/zulip/uploads/*/*```@@ -454,7 +454,7 @@ in the management shell before deleting the organization from thedatabase (this will be `2` for the first organization created on aZulip server, shown in the example below), e.g.:-```+```bashrm -rf /home/zulip/uploads/*/2/```diff --git a/docs/production/install-existing-server.md b/docs/production/install-existing-server.mdindex eed0c7a46e8..b3cd7b09695 100644--- a/docs/production/install-existing-server.md+++ b/docs/production/install-existing-server.md@@ -26,7 +26,7 @@ zulip.com](https://zulip.com)).Copy your existing nginx configuration to a backup and then merge theone created by Zulip into it:-```shell+```bashsudo cp /etc/nginx/nginx.conf /etc/nginx.conf.before-zulip-installsudo curl -fL -o /etc/nginx/nginx.conf.zulip \https://raw.githubusercontent.com/zulip/zulip/master/puppet/zulip/templates/nginx.conf.template.erb@@ -43,7 +43,7 @@ installs.After the Zulip installation completes, then you can overwrite (ormerge) your new nginx.conf with the installed one:-```shell+```console$ sudo meld /etc/nginx/nginx.conf.zulip /etc/nginx/nginx.conf # be sure to merge to the right$ sudo service nginx restart```@@ -58,13 +58,13 @@ If you have a Puppet server running on your server, you will get anerror message about not being able to connect to the client during theinstall process:-```shell+```consolepuppet-agent[29873]: Could not request certificate: Failed to open TCP connection to puppet:8140```So you'll need to shut down any Puppet servers.-```shell+```console$ sudo service puppet-agent stop$ sudo service puppet stop```diff --git a/docs/production/install.md b/docs/production/install.mdindex 043a39887b0..77e5e666387 100644--- a/docs/production/install.md+++ b/docs/production/install.md@@ -18,7 +18,7 @@ Download and unpack [the latest built servertarball](https://www.zulip.org/dist/releases/zulip-server-latest.tar.gz)with the following commands:-```+```bashcd $(mktemp -d)curl -fLO https://www.zulip.org/dist/releases/zulip-server-latest.tar.gztar -xf zulip-server-latest.tar.gz@@ -35,7 +35,7 @@ using code from our [repository on GitHub](https://github.com/zulip/zulip/).To set up Zulip with the most common configuration, you can run theinstaller as follows:-```+```bashsudo -s # If not already root./zulip-server-*/scripts/setup/install --certbot \--email=YOUR_EMAIL --hostname=YOUR_HOSTNAMEdiff --git a/docs/production/management-commands.md b/docs/production/management-commands.mdindex fb83d1dadee..641fe3b39a3 100644--- a/docs/production/management-commands.md+++ b/docs/production/management-commands.md@@ -10,7 +10,7 @@ framework][django-management].Start by logging in as the `zulip` user on the Zulip server. Then runthem as follows:-```+```bashcd /home/zulip/deployments/current# Start by reading the help@@ -39,7 +39,7 @@ string ID (usually the subdomain).You can see all the organizations on your Zulip server using`./manage.py list_realms`.-```+```consolezulip@zulip:~$ /home/zulip/deployments/current/manage.py list_realmsid string_id name-- --------- ----@@ -56,7 +56,7 @@ Unless you areyour single Zulip organization on the root domain will have the emptystring (`''`) as its `string_id`. So you can run e.g.:-```+```consolezulip@zulip:~$ /home/zulip/deployments/current/manage.py show_admins -r ''```@@ -73,7 +73,7 @@ You can get an IPython shell with full access to code within the Zulipproject using `manage.py shell`, e.g., you can do the following tochange a user's email address:-```+```console$ cd /home/zulip/deployments/current/$ ./manage.py shellIn [1]: user_profile = get_user_profile_by_email("[email protected]")diff --git a/docs/production/mobile-push-notifications.md b/docs/production/mobile-push-notifications.mdindex 3d0e82a6a8e..e63bf8dca57 100644--- a/docs/production/mobile-push-notifications.md+++ b/docs/production/mobile-push-notifications.md@@ -34,7 +34,7 @@ You can enable this for your Zulip server as follows:1. If you're running Zulip 1.8.1 or newer, you can run theregistration command:- ```+ ```bash# As root:su zulip -c '/home/zulip/deployments/current/manage.py register_server'# Or as the zulip user, you can skip the `su zulip -c`:diff --git a/docs/production/multiple-organizations.md b/docs/production/multiple-organizations.mdindex 113dc91ebfd..fdc218463a9 100644--- a/docs/production/multiple-organizations.md+++ b/docs/production/multiple-organizations.md@@ -71,7 +71,7 @@ If you'd like to use hostnames that are not subdomains of each other,you can set the `REALM_HOSTS` setting in `/etc/zulip/settings.py` to aPython dictionary, like this:-```+```pythonREALM_HOSTS = {'mysubdomain': 'hostname.example.com',}diff --git a/docs/production/postgresql.md b/docs/production/postgresql.mdindex 3460dd2006b..40e61fa810f 100644--- a/docs/production/postgresql.md+++ b/docs/production/postgresql.md@@ -53,13 +53,13 @@ PostgreSQL documentation):Then you should specify the password of the user zulip for thedatabase in /etc/zulip/zulip-secrets.conf:-```+```inipostgres_password = xxxx```Finally, you can stop your database on the Zulip server via:-```+```bashsudo service postgresql stopsudo update-rc.d postgresql disable```@@ -76,7 +76,7 @@ can give you some tips.When debugging PostgreSQL issues, in addition to the standard `pg_top`tool, often it can be useful to use this query:-```+```postgresqlSELECT procpid,waiting,query_start,current_query FROM pg_stat_activity ORDER BY procpid;```@@ -97,7 +97,7 @@ and enter recovery mode.To start or stop PostgreSQL manually, use the pg_ctlcluster command:-```+```bashpg_ctlcluster 9.1 [--force] main {start|stop|restart|reload}```@@ -128,7 +128,7 @@ database failed to start. It may tell you to check the logs, but youwon't find any information there. pg_ctlcluster runs the followingcommand underneath when it actually goes to start PostgreSQL:-```+```bash/usr/lib/postgresql/9.1/bin/pg_ctl start -D /var/lib/postgresql/9.1/main -s -o \'-c config_file="/etc/postgresql/9.1/main/postgresql.conf"'```diff --git a/docs/production/requirements.md b/docs/production/requirements.mdindex ee526738275..1c2884cc2b3 100644--- a/docs/production/requirements.md+++ b/docs/production/requirements.md@@ -38,7 +38,7 @@ If you're using Ubuntu, the[Ubuntu universe repository][ubuntu-repositories] must be[enabled][enable-universe], which is usually just:-```+```bashsudo add-apt-repository universesudo apt update```diff --git a/docs/production/settings.md b/docs/production/settings.mdindex aa191e95173..cf18c8e656f 100644--- a/docs/production/settings.md+++ b/docs/production/settings.md@@ -15,7 +15,7 @@ This page discusses additional configuration that a systemadministrator can do. To change any of the following settings, editthe `/etc/zulip/settings.py` file on your Zulip server, and thenrestart the server with the following command:-```+```bashsu zulip -c '/home/zulip/deployments/current/scripts/restart-server'```diff --git a/docs/production/ssl-certificates.md b/docs/production/ssl-certificates.mdindex 43953ac718b..4d2403b95a6 100644--- a/docs/production/ssl-certificates.md+++ b/docs/production/ssl-certificates.md@@ -84,7 +84,7 @@ one as described in the section below after installing Zulip.To enable the Certbot automation on an already-installed Zulipserver, run the following commands:-```+```bashsudo -s # If not already root/home/zulip/deployments/current/scripts/setup/setup-certbot --email=EMAIL HOSTNAME [HOSTNAME2...]```@@ -125,7 +125,7 @@ just pass the `--self-signed-cert` flag whenTo generate a self-signed certificate for an already-installed Zulipserver, run the following commands:-```+```bashsudo -s # If not already root/home/zulip/deployments/current/scripts/setup/generate-self-signed-cert HOSTNAME```@@ -134,7 +134,7 @@ generated certificate.After replacing the certificates, you need to reload `nginx` byrunning the following as `root`:-```+```bashservice nginx reload```diff --git a/docs/production/troubleshooting.md b/docs/production/troubleshooting.mdindex 0e88c82e738..748e38ebddd 100644--- a/docs/production/troubleshooting.md+++ b/docs/production/troubleshooting.md@@ -37,13 +37,13 @@ and restart various services.### Checking status with `supervisorctl status`You can check if the Zulip application is running using:-```+```bashsupervisorctl status```When everything is running as expected, you will see something like this:-```+```consoleprocess-fts-updates RUNNING pid 11392, uptime 19:40:06smokescreen RUNNING pid 3113, uptime 29 days, 21:58:32teleport_node RUNNING pid 15683, uptime 3 days, 13:01:58@@ -82,7 +82,7 @@ After you change configuration in `/etc/zulip/settings.py` or fix amisconfiguration, you will often want to restart the Zulip application.You can restart Zulip using:-```+```bashsupervisorctl restart all```@@ -90,7 +90,7 @@ supervisorctl restart allSimilarly, you can stop Zulip using:-```+```bashsupervisorctl stop all```@@ -118,13 +118,13 @@ problems and how to resolve them:nginx will fail to start if you configured SSL incorrectly or didnot provide SSL certificates. To fix this, configure them properlyand then run:- ```+ ```bashservice nginx restart```* If your host is being port scanned by unauthorized users, you may seemessages in `/var/log/zulip/server.log` like- ```+ ```text2017-02-22 14:11:33,537 ERROR Invalid HTTP_HOST header: '10.2.3.4'. You may need to add u'10.2.3.4' to ALLOWED_HOSTS.```Django uses the hostnames configured in `ALLOWED_HOSTS` to identify@@ -135,7 +135,7 @@ problems and how to resolve them:* An AMQPConnectionError traceback or error running rabbitmqctlusually means that RabbitMQ is not running; to fix this, try:- ```+ ```bashservice rabbitmq-server restart```If RabbitMQ fails to start, the problem is often that you are using@@ -182,7 +182,7 @@ You can ensure that the `unattended-upgrades` package never upgradesPostgreSQL, memcached, Redis, or RabbitMQ, by configuring in`/etc/apt/apt.conf.d/50unattended-upgrades`:-```+```text// Python regular expressions, matching packages to exclude from upgradingUnattended-Upgrade::Package-Blacklist {"libc\d+";diff --git a/docs/production/upgrade-or-modify.md b/docs/production/upgrade-or-modify.mdindex 82131ccbec5..a1619f66073 100644--- a/docs/production/upgrade-or-modify.md+++ b/docs/production/upgrade-or-modify.md@@ -27,7 +27,7 @@ to a new Zulip release:<https://www.zulip.org/dist/releases/> You can download the latestrelease with:- ```+ ```bashcurl -fLO https://www.zulip.org/dist/releases/zulip-server-latest.tar.gz```@@ -39,7 +39,7 @@ to a new Zulip release:1. Log in to your Zulip and run as root:- ```+ ```bash/home/zulip/deployments/current/scripts/upgrade-zulip zulip-server-VERSION.tar.gz```@@ -71,7 +71,7 @@ Git repository, which is great for [running pre-release changes frommaster](#applying-changes-from-master) or [maintaining afork](#making-changes). The process is simple:-```+```bash# Upgrade to an official release/home/zulip/deployments/current/scripts/upgrade-zulip-from-git 1.8.1# Upgrade to a branch (or other Git ref)@@ -95,7 +95,7 @@ By default, this uses the main upstream Zulip server repository, butyou can configure any other Git repository by adding a section likethis to `/etc/zulip/zulip.conf`:-```+```ini[deployment]git_repo_url = https://github.com/zulip/zulip.git```@@ -123,7 +123,7 @@ suggest using that updated template to updatedo not have a recent [complete backup][backups]), and make a copyof the current template:- ```+ ```bashcp -a /etc/zulip/settings.py ~/zulip-settings-backup.pycp -a /home/zulip/deployments/current/zproject/prod_settings_template.py /etc/zulip/settings-new.py```@@ -137,7 +137,7 @@ suggest using that updated template to updatethe template that your `/etc/zulip/settings.py` was installedusing, and the differences that your file has from that:- ```+ ```bash/home/zulip/deployments/current/scripts/setup/compare-settings-to-template```@@ -149,7 +149,7 @@ suggest using that updated template to updatethe server to pick up the new file; this should be a no-op, but itis much better to discover immediately if it is not:- ```+ ```bashcp -a /etc/zulip/settings-new.py /etc/zulip/settings.pysu zulip -c '/home/zulip/deployments/current/scripts/restart-server'```@@ -260,7 +260,7 @@ instructions for other supported platforms.2. As the Zulip user, stop the Zulip server and run the followingto back up the system:- ```+ ```bashsupervisorctl stop all/home/zulip/deployments/current/manage.py backup --output=/home/zulip/release-upgrade.backup.tar.gz```@@ -270,7 +270,7 @@ instructions for other supported platforms.`do-release-upgrade` and following the prompts until it completessuccessfully:- ```+ ```bashsudo -i # Or otherwise get a root shelldo-release-upgrade```@@ -283,7 +283,7 @@ instructions for other supported platforms.4. As root, upgrade the database to the latest version of PostgreSQL:- ```+ ```bash/home/zulip/deployments/current/scripts/setup/upgrade-postgresql```@@ -292,7 +292,7 @@ instructions for other supported platforms."collations"); this corrupts database indexes that rely oncollations. Regenerate the affected indexes by running:- ```+ ```bash/home/zulip/deployments/current/scripts/setup/reindex-textual-data --force```@@ -302,7 +302,7 @@ instructions for other supported platforms.full-text search indexes to work with the upgraded dictionarypackages:- ```+ ```bashrm -rf /srv/zulip-venv-cache/*/home/zulip/deployments/current/scripts/lib/upgrade-zulip-stage-2 \/home/zulip/deployments/current/ --ignore-static-assets --audit-fts-indexes@@ -325,7 +325,7 @@ instructions for other supported platforms.4. As root, upgrade the database installation and OS configuration tomatch the new OS version:- ```+ ```bashtouch /usr/share/postgresql/10/pgroonga_setup.sql.applied/home/zulip/deployments/current/scripts/zulip-puppet-apply -fpg_dropcluster 10 main --stop@@ -341,7 +341,7 @@ instructions for other supported platforms.among other things will recompile Zulip's Python moduledependencies for your new version of Python:- ```+ ```bashrm -rf /srv/zulip-venv-cache/*/home/zulip/deployments/current/scripts/lib/upgrade-zulip-stage-2 \/home/zulip/deployments/current/ --ignore-static-assets@@ -356,7 +356,7 @@ instructions for other supported platforms.7. As root, finish by verifying the contents of the full-text indexes:- ```+ ```bash/home/zulip/deployments/current/manage.py audit_fts_indexes```@@ -373,7 +373,7 @@ instructions for other supported platforms.4. As root, upgrade the database installation and OS configuration tomatch the new OS version:- ```+ ```bashapt remove upstart -y/home/zulip/deployments/current/scripts/zulip-puppet-apply -fpg_dropcluster 9.5 main --stop@@ -389,7 +389,7 @@ instructions for other supported platforms.among other things will recompile Zulip's Python moduledependencies for your new version of Python:- ```+ ```bashrm -rf /srv/zulip-venv-cache/*/home/zulip/deployments/current/scripts/lib/upgrade-zulip-stage-2 \/home/zulip/deployments/current/ --ignore-static-assets@@ -424,7 +424,7 @@ instructions for other supported platforms.4. As root, upgrade the database installation and OS configuration tomatch the new OS version:- ```+ ```bashapt remove upstart -y/home/zulip/deployments/current/scripts/zulip-puppet-apply -fpg_dropcluster 11 main --stop@@ -440,7 +440,7 @@ instructions for other supported platforms.among other things will recompile Zulip's Python moduledependencies for your new version of Python:- ```+ ```bashrm -rf /srv/zulip-venv-cache/*/home/zulip/deployments/current/scripts/lib/upgrade-zulip-stage-2 \/home/zulip/deployments/current/ --ignore-static-assets@@ -458,13 +458,13 @@ instructions for other supported platforms."collations"); this corrupts database indexes that rely oncollations. Regenerate the affected indexes by running:- ```+ ```bash/home/zulip/deployments/current/scripts/setup/reindex-textual-data --force```8. As root, finish by verifying the contents of the full-text indexes:- ```+ ```bash/home/zulip/deployments/current/manage.py audit_fts_indexes```@@ -482,14 +482,14 @@ To upgrade the version of PostgreSQL on the Zulip server:2. Stop the server and take a backup:- ```+ ```bashsupervisorctl stop all/home/zulip/deployments/current/manage.py backup --output=/home/zulip/postgresql-upgrade.backup.tar.gz```3. As root, run the database upgrade tool:- ```+ ```bash/home/zulip/deployments/current/scripts/setup/upgrade-postgresql```@@ -553,7 +553,7 @@ Git guide][git-guide] if you need a primer):[GitHub](https://github.com).* Create a branch (named `acme-branch` below) containing your changes:-```+```bashcd zulipgit checkout -b acme-branch 2.0.4```@@ -561,7 +561,7 @@ git checkout -b acme-branch 2.0.4* Use your favorite code editor to modify Zulip.* Commit your changes and push them to GitHub:-```+```bashgit commit -a# Use `git diff` to verify your changes are what you expect@@ -597,7 +597,7 @@ Otherwise, you'll need to update your branch by rebasing your changesrepository). The example below assumes you have a branch off of 2.0.4and want to upgrade to 2.1.0.-```+```bashcd zulipgit fetch --tags upstreamgit checkout acme-branch@@ -640,7 +640,7 @@ fixes on your local Zulip server without waiting for an official release.Many bugs have small/simple fixes. In this case, you can use the Gitworkflow [described above](#making-changes), using:-```+```bashgit fetch upstreamgit cherry-pick abcd1234```diff --git a/docs/production/upload-backends.md b/docs/production/upload-backends.mdindex 9ab225fa68b..426a1854013 100644--- a/docs/production/upload-backends.md+++ b/docs/production/upload-backends.md@@ -50,7 +50,7 @@ as world-readable, whereas the "uploaded files" one is not.With Zulip 1.9.0 and newer, you can do this automatically with thefollowing commands run as root:- ```+ ```bashcrudini --set /etc/zulip/zulip.conf application_server no_serve_uploads true/home/zulip/deployments/current/scripts/zulip-puppet-apply```@@ -83,7 +83,7 @@ each of the two buckets, you'll want to[add an S3 bucket policy](https://awspolicygen.s3.amazonaws.com/policygen.html)entry that looks something like this:-```+```json{"Version": "2012-10-17","Id": "Policy1468991802321",@@ -117,7 +117,7 @@ entry that looks something like this:The avatars bucket is intended to be world-readable, so you'll alsoneed a block like this:-```+```json{"Sid": "Stmt1468991795389","Effect": "Allow",diff --git a/docs/subsystems/caching.md b/docs/subsystems/caching.mdindex 61c2c8205fd..9046d96cc6b 100644--- a/docs/subsystems/caching.md+++ b/docs/subsystems/caching.md@@ -132,7 +132,7 @@ you configure some code to run every time Django does something (forThere's a handful of lines in `zerver/models.py` like these thatconfigure this:-```+```pythonpost_save.connect(flush_realm, sender=Realm)post_save.connect(flush_user_profile, sender=UserProfile)```diff --git a/docs/subsystems/email.md b/docs/subsystems/email.mdindex bc615c842fb..0d7fd1754ca 100644--- a/docs/subsystems/email.md+++ b/docs/subsystems/email.md@@ -90,7 +90,7 @@ following keys in `zproject/dev-secrets.conf`Here is an example of how `zproject/dev-secrets.conf` might look ifyou are using Gmail.-```+```iniemail_host = smtp.gmail.comemail_port = 587email_host_user = [email protected]diff --git a/docs/subsystems/events-system.md b/docs/subsystems/events-system.mdindex 4a3aa89e979..0f7f24ae0e3 100644--- a/docs/subsystems/events-system.md+++ b/docs/subsystems/events-system.md@@ -233,11 +233,13 @@ ready to write a test in `test_events.py`.The actual code for a `test_events` test can be quite concise:- def test_default_streams_events(self) -> None:- stream = get_stream("Scotland", self.user_profile.realm)- events = self.verify_action(lambda: do_add_default_stream(stream))- check_default_streams("events[0]", events[0])- # (some details omitted)+```python+def test_default_streams_events(self) -> None:+ stream = get_stream("Scotland", self.user_profile.realm)+ events = self.verify_action(lambda: do_add_default_stream(stream))+ check_default_streams("events[0]", events[0])+ # (some details omitted)+```The real trick is debugging these tests.@@ -292,23 +294,25 @@ only has one required parameter, which is the action function. Wetypically express the action function as a lambda, so that wecan pass in arguments:- events = self.verify_action(lambda: do_add_default_stream(stream))+```python+events = self.verify_action(lambda: do_add_default_stream(stream))+```There are some notable optional parameters for `verify_action`:- * `state_change_expected` must be set to `False` if your action- doesn't actually require state changes for some reason; otherwise,- `verify_action` will complain that your test doesn't really- exercise any `apply_events` logic. Typing notifications (which- are ephemereal) are a common place where we use this.+* `state_change_expected` must be set to `False` if your action+ doesn't actually require state changes for some reason; otherwise,+ `verify_action` will complain that your test doesn't really+ exercise any `apply_events` logic. Typing notifications (which+ are ephemereal) are a common place where we use this.- * `num_events` will tell `verify_action` how many events the- `hamlet` user will receive after the action (the default is 1).+* `num_events` will tell `verify_action` how many events the+ `hamlet` user will receive after the action (the default is 1).- * parameters such as `client_gravatar` and `slim_presence` get- passed along to `fetch_initial_state_data` (and it's important- to test both boolean values of these parameters for relevant- actions).+* parameters such as `client_gravatar` and `slim_presence` get+ passed along to `fetch_initial_state_data` (and it's important+ to test both boolean values of these parameters for relevant+ actions).For advanced use cases of `verify_action`, we highly recommend readingthe code itself in `BaseAction` (in `test_events.py`).@@ -327,9 +331,11 @@ The second is higher-detail check inside `test_events` that thisspecific test generated the expected series of events. Let's look atthe last line of our example test snippet:- # ...- events = self.verify_action(lambda: do_add_default_stream(stream))- check_default_streams("events[0]", events[0])+```python+# ...+events = self.verify_action(lambda: do_add_default_stream(stream))+check_default_streams("events[0]", events[0])+```We have discussed `verify_action` in some detail, and you willnote that it returns the actual events generated by the action@@ -346,13 +352,15 @@ If you are creating a new event format, then you will have towrite your own schema checker in `event_schema.py`. Here isthe example relevant to our example:- default_streams_event = event_dict_type(- required_keys=[- ("type", Equals("default_streams")),- ("default_streams", ListType(DictType(basic_stream_fields))),- ]- )- check_default_streams = make_checker(default_streams_event)+```python+default_streams_event = event_dict_type(+ required_keys=[+ ("type", Equals("default_streams")),+ ("default_streams", ListType(DictType(basic_stream_fields))),+ ]+)+check_default_streams = make_checker(default_streams_event)+```Note that `basic_stream_fields` is not shown in these docs. Thebest way to understand how to write schema checkers is to readdiff --git a/docs/subsystems/full-text-search.md b/docs/subsystems/full-text-search.mdindex 514c71f2b5b..96d9e7adac4 100644--- a/docs/subsystems/full-text-search.md+++ b/docs/subsystems/full-text-search.md@@ -41,33 +41,44 @@ All steps in this section should be run as the `root` user; on most installs, th1. Alter the deployment setting:- crudini --set /etc/zulip/zulip.conf machine pgroonga enabled+ ```bash+ crudini --set /etc/zulip/zulip.conf machine pgroonga enabled+ ```1. Update the deployment to respect that new setting:- /home/zulip/deployments/current/scripts/zulip-puppet-apply+ ```bash+ /home/zulip/deployments/current/scripts/zulip-puppet-apply+ ```1. Edit `/etc/zulip/settings.py`, to add:- USING_PGROONGA = True+ ```python+ USING_PGROONGA = True+ ```1. Apply the PGroonga migrations:- su zulip -c '/home/zulip/deployments/current/manage.py migrate pgroonga'+ ```bash+ su zulip -c '/home/zulip/deployments/current/manage.py migrate pgroonga'+ ```Note that the migration may take a long time, and users will beunable to send new messages until the migration finishes.1. Once the migrations are complete, restart Zulip:- su zulip -c '/home/zulip/deployments/current/scripts/restart-server'-+ ```bash+ su zulip -c '/home/zulip/deployments/current/scripts/restart-server'+ ```### Disabling PGroonga1. Remove the PGroonga migration:- su zulip -c '/home/zulip/deployments/current/manage.py migrate pgroonga zero'+ ```bash+ su zulip -c '/home/zulip/deployments/current/manage.py migrate pgroonga zero'+ ```If you intend to re-enable PGroonga later, you can skip this step,at the cost of your Message table being slightly larger than it would@@ -75,12 +86,18 @@ All steps in this section should be run as the `root` user; on most installs, th1. Edit `/etc/zulip/settings.py`, editing the line containing `USING_PGROONGA` to read:- USING_PGROONGA = False+ ```python+ USING_PGROONGA = False+ ```1. Restart Zulip:- su zulip -c '/home/zulip/deployments/current/scripts/restart-server'+ ```bash+ su zulip -c '/home/zulip/deployments/current/scripts/restart-server'+ ```1. Finally, remove the deployment setting:- crudini --del /etc/zulip/zulip.conf machine pgroonga+ ```bash+ crudini --del /etc/zulip/zulip.conf machine pgroonga+ ```diff --git a/docs/subsystems/hotspots.md b/docs/subsystems/hotspots.mdindex f0dbdbf07d5..4f01d64555a 100644--- a/docs/subsystems/hotspots.md+++ b/docs/subsystems/hotspots.md@@ -17,7 +17,7 @@ In `zerver/lib/hotspots.py`, add your content to the `ALL_HOTSPOTS` dictionary.Each key-value pair in `ALL_HOTSPOTS` associates the name of the hotspot with thecontent displayed to the user.-```+```pythonALL_HOTSPOTS = {...'new_hotspot_name': {@@ -67,8 +67,8 @@ a target element on a sidebar or overlay, the icon's z-index may need tobe increased to 101, 102, or 103.This adjustment can be made at the bottom of `static/styles/hotspots.css`:-```-\#hotspot_new_hotspot_name_icon {+```css+#hotspot_new_hotspot_name_icon {z-index: 103;}```diff --git a/docs/subsystems/html-css.md b/docs/subsystems/html-css.mdindex ed5bf8769c0..4b3cb366235 100644--- a/docs/subsystems/html-css.md+++ b/docs/subsystems/html-css.md@@ -91,7 +91,7 @@ the default context available to all Jinja2 templates.renders the template. For example, if you want to find the contextpassed to `index.html`, you can do:-```+```console$ git grep zerver/app/index.html '*.py'zerver/views/home.py: response = render(request, 'zerver/app/index.html',```@@ -101,7 +101,7 @@ The next line in the code being the context definition.* `zproject/urls.py` for some fairly static pages that are renderedusing `TemplateView`, for example:-```+```pythonpath('config-error/google', TemplateView.as_view(template_name='zerver/config_error.html',),{'google_error': True},),diff --git a/docs/subsystems/logging.md b/docs/subsystems/logging.mdindex 0b20416e32f..6df6c4205f7 100644--- a/docs/subsystems/logging.md+++ b/docs/subsystems/logging.md@@ -71,7 +71,7 @@ In production, one usually wants to look at `errors.log` for errorssince the main server log can be very verbose, but the main server logcan be extremely valuable for investigating performance problems.-```+```text2016-05-20 14:50:22.056 INFO [zr] 127.0.0.1 GET 302 528ms (db: 1ms/1q) (+start: 123ms) / (unauth@zulip via ?)[20/May/2016 14:50:22]"GET / HTTP/1.0" 302 02016-05-20 14:50:22.272 INFO [zr] 127.0.0.1 GET 200 124ms (db: 3ms/2q) /login/ (unauth@zulip via ?)diff --git a/docs/subsystems/queuing.md b/docs/subsystems/queuing.mdindex f90494de534..9485a61c5f8 100644--- a/docs/subsystems/queuing.md+++ b/docs/subsystems/queuing.md@@ -75,14 +75,14 @@ processor's code path, but it isn't always possible.If you need to clear a queue (delete all the events in it), run`./manage.py purge_queue <queue_name>`, for example:-```+```bash./manage.py purge_queue user_activity```You can also use the amqp tools directly. Install `amqp-tools` fromapt and then run:-```+```bashamqp-delete-queue --username=zulip --password='...' --server=localhost \--queue=user_presence```diff --git a/docs/subsystems/realms.md b/docs/subsystems/realms.mdindex 70d1243d5e1..9dd688a5614 100644--- a/docs/subsystems/realms.md+++ b/docs/subsystems/realms.md@@ -25,7 +25,7 @@ There are two main methods for creating realms.#### Using unique link generator```bash- ./manage.py generate_realm_creation_link+./manage.py generate_realm_creation_link```The above command will output a URL which can be used for creating a@@ -80,7 +80,7 @@ lookup should still work even if you disable proxy for*.zulipdev.com. If it doesn't you can add zulipdev.com records in`/etc/hosts` file. The file should look something like this.- ```+```text127.0.0.1 localhost127.0.0.1 zulipdev.comdiff --git a/docs/subsystems/schema-migrations.md b/docs/subsystems/schema-migrations.mdindex 925b2c393c7..287e544c9f0 100644--- a/docs/subsystems/schema-migrations.md+++ b/docs/subsystems/schema-migrations.md@@ -93,7 +93,7 @@ migrations.Another important note is that making changes to the data in a tablevia `RunPython` code and `ALTER TABLE` operations within a single,atomic migration don't mix well. If you encounter an error such as- ```+ ```textdjango.db.utils.OperationalError: cannot ALTER TABLE "table_name" because it has pending trigger events```when testing the migration, the reason is often that these operationsdiff --git a/docs/subsystems/settings.md b/docs/subsystems/settings.mdindex 01fb6335f1a..3604b63ee10 100644--- a/docs/subsystems/settings.md+++ b/docs/subsystems/settings.md@@ -30,7 +30,7 @@ means that the settings files are Python programs that set a lot ofvariables with all-capital names like `EMAIL_GATEWAY_PATTERN`. You canaccess these anywhere in the Zulip Django code using e.g.:-```+```pythonfrom django.conf import settingsprint(settings.EMAIL_GATEWAY_PATTERN)```@@ -38,7 +38,7 @@ print(settings.EMAIL_GATEWAY_PATTERN)Additionally, if you need to access a Django setting in a shellscript (or just on the command line for debugging), you can use e.g.:-```+```console$ ./scripts/get-django-setting EMAIL_GATEWAY_PATTERN%s@localhost:9991```diff --git a/docs/subsystems/unread_messages.md b/docs/subsystems/unread_messages.mdindex 2f5720117d6..027cc24ccbf 100644--- a/docs/subsystems/unread_messages.md+++ b/docs/subsystems/unread_messages.md@@ -12,7 +12,7 @@ state grouped by relevant conversation keys. This data is included in the`unread_msgs` key if both `update_message_flags` and `message` are requiredin the register call.-```+```json{"count": 4,"huddles": [diff --git a/docs/testing/linters.md b/docs/testing/linters.mdindex 0d4daef07f7..cbf0837e88c 100644--- a/docs/testing/linters.md+++ b/docs/testing/linters.md@@ -43,9 +43,11 @@ and exempting legacy files from lint checks.If you run `./tools/test-all`, it will automatically run the linters.You can also run them individually or pass specific files:- ./tools/lint- ./tools/lint static/js/compose.js- ./tools/lint static/js/+```bash+./tools/lint+./tools/lint static/js/compose.js+./tools/lint static/js/+````./tools/lint` has many useful options; you can read about them in itsinternal documentation using `./tools/lint --help`. Of particulardiff --git a/docs/testing/mypy.md b/docs/testing/mypy.mdindex cf71e26e5f4..25c9b5493f7 100644--- a/docs/testing/mypy.md+++ b/docs/testing/mypy.md@@ -48,7 +48,9 @@ requirements/mypy.txt`.To run mypy on Zulip's python code, you can run the command:- tools/run-mypy+```bash+tools/run-mypy+```Mypy outputs errors in the same style as a compiler would. Forexample, if your code has a type error like this:@@ -60,7 +62,7 @@ foo = '1'you'll get an error like this:-```+```consoletest.py: note: In function "test":test.py:200: error: Incompatible types in assignment (expression has type "str", variable has type "int")```@@ -507,7 +509,7 @@ have untracked files in your Zulip checkout safely). So if you get a`mypy` error like this after adding a new file that is referenced bythe existing codebase:-```+```consolemypy | zerver/models.py:1234: note: Import of 'zerver.lib.markdown_wrappers' ignoredmypy | zerver/models.py:1234: note: (Using --follow-imports=error, module not passed on command line)```diff --git a/docs/testing/testing-with-django.md b/docs/testing/testing-with-django.mdindex 314fdea585d..eb30440f641 100644--- a/docs/testing/testing-with-django.md+++ b/docs/testing/testing-with-django.md@@ -30,14 +30,18 @@ on a fast machine. When you are in iterative mode, you can runindividual tests or individual modules, following the dotted.test.nameconvention below:- cd /srv/zulip- ./tools/test-backend zerver.tests.test_queue_worker.WorkerTest+```bash+cd /srv/zulip+./tools/test-backend zerver.tests.test_queue_worker.WorkerTest+```There are many command line options for running Zulip tests, suchas a `--verbose` option. Thebest way to learn the options is to use the online help:- ./tools/test-backend --help+```bash+./tools/test-backend --help+```We also have ways to instrument our tests for finding code coverage,URL coverage, and slow tests. Use the `-h` option to discover these@@ -176,24 +180,28 @@ analyzed.Say you have a module `greetings` defining the following functions:- def fetch_database(key: str) -> str:- # ...- # Do some look-ups in a database- return data+```python+def fetch_database(key: str) -> str:+ # ...+ # Do some look-ups in a database+ return data- def greet(name_key: str) -> str:- name = fetch_database(name_key)- return "Hello" + name+def greet(name_key: str) -> str:+ name = fetch_database(name_key)+ return "Hello" + name+```* You want to test `greet()`.* In your test, you want to call `greet("Mario")` and verify that it returns the correct greeting:- from greetings import greet+ ```python+ from greetings import greet- def test_greet() -> str:- greeting = greet("Mario")- assert greeting == "Hello Mr. Mario Mario"+ def test_greet() -> str:+ greeting = greet("Mario")+ assert greeting == "Hello Mr. Mario Mario"+ ```-> **You have a problem**: `greet()` calls `fetch_database()`. `fetch_database()` does some look-ups ina database. *You haven't created that database for your tests, so your test would fail, even though@@ -206,15 +214,17 @@ Say you have a module `greetings` defining the following functions:-> **Solution**: You mock `fetch_database()`. This is also referred to as "mocking out" `fetch_database()`.- from unittest.mock import patch+```python+from unittest.mock import patch- def test_greet() -> None:- # Mock `fetch_database()` with an object that acts like a shell: It still accepts calls like `fetch_database()`,- # but doesn't do any database lookup. We "fill" the shell with a return value; This value will be returned on every- # call to `fetch_database()`.- with patch("greetings.fetch_database", return_value="Mr. Mario Mario"):- greeting = greetings.greet("Mario")- assert greeting == "Hello Mr. Mario Mario"+def test_greet() -> None:+ # Mock `fetch_database()` with an object that acts like a shell: It still accepts calls like `fetch_database()`,+ # but doesn't do any database lookup. We "fill" the shell with a return value; This value will be returned on every+ # call to `fetch_database()`.+ with patch("greetings.fetch_database", return_value="Mr. Mario Mario"):+ greeting = greetings.greet("Mario")+ assert greeting == "Hello Mr. Mario Mario"+```That's all. Note that **this mock is suitable for testing `greet()`, but not for testing `fetch_database()`**.More generally, you should only mock those functions you explicitly don't want to test.@@ -230,17 +240,21 @@ those are the ones starting with with a dunder `__`). From the docs:`Mock` itself is a class that principally accepts and records any and all calls. A piece of code like- from unittest import mock+```python+from unittest import mock- foo = mock.Mock()- foo.bar('quux')- foo.baz- foo.qux = 42+foo = mock.Mock()+foo.bar('quux')+foo.baz+foo.qux = 42+```is *not* going to throw any errors. Our mock silently accepts all these calls and records them.`Mock` also implements methods for us to access and assert its records, e.g.- foo.bar.assert_called_with('quux')+```python+foo.bar.assert_called_with('quux')+```Finally, `unittest.mock` also provides a method to mock objects only within a scope: `patch()`. We can use `patch()` eitheras a decorator or as a context manager. In both cases, the mock created by `patch()` will apply for the scope of the decorator /@@ -248,13 +262,15 @@ context manager. `patch()` takes only one required argument `target`. `target` ithe name of the object you want to mock*. It will then assign a `MagicMock()` to that object.As an example, look at the following code:- from unittest import mock- from os import urandom+```python+from unittest import mock+from os import urandom- with mock.patch('__main__.urandom', return_value=42):- print(urandom(1))- print(urandom(1)) # No matter what value we plug in for urandom, it will always return 42.- print(urandom(1)) # We exited the context manager, so the mock doesn't apply anymore. Will return a random byte.+with mock.patch('__main__.urandom', return_value=42):+ print(urandom(1))+ print(urandom(1)) # No matter what value we plug in for urandom, it will always return 42.+print(urandom(1)) # We exited the context manager, so the mock doesn't apply anymore. Will return a random byte.+```*Note that calling `mock.patch('os.urandom', return_value=42)` wouldn't work here*: `os.urandom` would be the name of our patchedobject. However, we imported `urandom` with `from os import urandom`; hence, we bound the `urandom` name to our current module@@ -266,27 +282,35 @@ On the other hand, if we had used `import os.urandom`, we would need to call `mo* Including the Python mocking library:- from unittest import mock+ ```python+ from unittest import mock+ ```* Mocking a class with a context manager:- with mock.patch('module.ClassName', foo=42, return_value='I am a mock') as my_mock:- # In here, 'module.ClassName' is mocked with a MagicMock() object my_mock.- # my_mock has an attribute named foo with the value 42.- # var = module.ClassName() will assign 'I am a mock' to var.+ ```python+ with mock.patch('module.ClassName', foo=42, return_value='I am a mock') as my_mock:+ # In here, 'module.ClassName' is mocked with a MagicMock() object my_mock.+ # my_mock has an attribute named foo with the value 42.+ # var = module.ClassName() will assign 'I am a mock' to var.+ ```* Mocking a class with a decorator:- @mock.patch('module.ClassName', foo=42, return_value='I am a mock')- def my_function(my_mock):- # ...- # In here, 'module.ClassName' will behave as in the previous example.+ ```python+ @mock.patch('module.ClassName', foo=42, return_value='I am a mock')+ def my_function(my_mock):+ # ...+ # In here, 'module.ClassName' will behave as in the previous example.+ ```* Mocking a class attribute:- with mock.patch.object(module.ClassName, 'class_method', return_value=42)- # In here, 'module.ClassName' has the same properties as before, except for 'class_method'- # Calling module.ClassName.class_method() will now return 42.+ ```python+ with mock.patch.object(module.ClassName, 'class_method', return_value=42)+ # In here, 'module.ClassName' has the same properties as before, except for 'class_method'+ # Calling module.ClassName.class_method() will now return 42.+ ```Note the missing quotes around module.ClassName in the patch.object() call.@@ -296,11 +320,13 @@ For mocking we generally use the "mock" library and use `mock.patch` asa context manager or decorator. We also take advantage of some context managersfrom Django as well as our own custom helpers. Here is an example:- with self.settings(RATE_LIMITING=True):- with mock.patch('zerver.decorator.rate_limit_user') as rate_limit_mock:- api_result = my_webhook(request)+```python+with self.settings(RATE_LIMITING=True):+ with mock.patch('zerver.decorator.rate_limit_user') as rate_limit_mock:+ api_result = my_webhook(request)- self.assertTrue(rate_limit_mock.called)+self.assertTrue(rate_limit_mock.called)+```Follow [this link](../subsystems/settings.html#testing-non-default-settings) for moreinformation on the "settings" context manager.diff --git a/docs/testing/testing-with-node.md b/docs/testing/testing-with-node.mdindex ff6d3cf6ccc..cc3c305474d 100644--- a/docs/testing/testing-with-node.md+++ b/docs/testing/testing-with-node.md@@ -7,8 +7,8 @@ system since it is much (>100x) faster and also easier to do correctlythan the Puppeteer system.You can run this test suite as follows:-```- tools/test-js-with-node+```bash+tools/test-js-with-node```See `test-js-with-node --help` for useful options; even though the@@ -19,7 +19,7 @@ The JS unit tests are written to work with node. You can find themin `frontend_tests/node_tests`. Here is an example test from`frontend_tests/node_tests/stream_data.js`:-```+```js(function test_get_by_id() {stream_data.clear_subscriptions();var id = 42;@@ -109,19 +109,23 @@ different types of declarations depending on whether we want to:For all the modules where you want to run actual code, add statementslike the following toward the top of your test file:-> zrequire('util');-> zrequire('stream_data');-> zrequire('Filter', 'js/filter');+```js+zrequire('util');+zrequire('stream_data');+zrequire('Filter', 'js/filter');+```For modules that you want to completely stub out, use a pattern likethis:-> const reminder = mock_esm("../../static/js/reminder", {-> is_deferred_delivery: noop,-> });->-> // then maybe further down-> reminder.is_deferred_delivery = () => true;+```js+const reminder = mock_esm("../../static/js/reminder", {+ is_deferred_delivery: noop,+});++// then maybe further down+reminder.is_deferred_delivery = () => true;+```One can similarly stub out functions in a module's exported interfacewith either `noop` functions or actual code.@@ -132,13 +136,15 @@ this is a pretty strong code smell that the other module might belacking in cohesion, but sometimes it's not worth going down therabbit hole of trying to improve that. The pattern here is this:-> // Import real code.-> zrequire('narrow_state');->-> // And later...-> narrow_state.stream = function () {-> return 'office';-> };+```js+// Import real code.+zrequire('narrow_state');++// And later...+narrow_state.stream = function () {+ return 'office';+};+```## Creating new test modules@@ -151,8 +157,8 @@ in that directory to create a new test.You can automatically generate coverage reports for the JavaScript unittests like this:-```- tools/test-js-with-node --coverage+```bash+tools/test-js-with-node --coverage```If tests pass, you will get instructions to view coverage reportsdiff --git a/docs/testing/testing-with-puppeteer.md b/docs/testing/testing-with-puppeteer.mdindex ac611a9a805..c591bf9e0f6 100644--- a/docs/testing/testing-with-puppeteer.md+++ b/docs/testing/testing-with-puppeteer.md@@ -10,8 +10,8 @@ keyboard shortcuts, etc.).## Running testsYou can run this test suite as follows:-```- tools/test-js-with-puppeteer+```bash+tools/test-js-with-puppeteer```See `tools/test-js-with-puppeteer --help` for useful options,@@ -34,7 +34,7 @@ appears/disappears", or "Click on this HTML element".For example, this function might test the `x` keyboard shortcut toopen the compose box for a new private message:-```+```jsasync function test_private_message_compose_shortcut(page) {await page.keyboard.press("KeyX");await page.waitForSelector("#private_message_recipient", {visible: true});diff --git a/docs/testing/testing.md b/docs/testing/testing.mdindex 34531100d96..3f65507d815 100644--- a/docs/testing/testing.md+++ b/docs/testing/testing.md@@ -23,7 +23,7 @@ you're using Vagrant, you may need to enter it with `vagrant ssh`.You can run all of the test suites (similar to our continuous integration)as follows:-```+```bash./tools/test-all```@@ -31,7 +31,7 @@ However, you will rarely want to do this while actively developing,because it takes a long time. Instead, your edit/refresh cycle willtypically involve running subsets of the tests with commands like these:-```+```bash./tools/lint zerver/lib/actions.py # Lint the file you just changed./tools/test-backend zerver.tests.test_markdown.MarkdownTest.test_inline_youtube./tools/test-backend MarkdownTest # Run `test-backend --help` for more options@@ -140,7 +140,7 @@ depending on Internet access.This enforcement code results in the following exception:- ```+ ```pytbFile "tools/test-backend", line 120, in internet_guardraise Exception("Outgoing network requests are not allowed in the Zulip tests."Exception: Outgoing network requests are not allowed in the Zulip tests.diff --git a/docs/translating/internationalization.md b/docs/translating/internationalization.mdindex 8fdaeec30d2..262d12bd221 100644--- a/docs/translating/internationalization.md+++ b/docs/translating/internationalization.md@@ -139,7 +139,7 @@ template so that it can be translated.To mark a string for translation in a Jinja2 template, youcan use the `_()` function in the templates like this:-```+```jinja{{ _("English text") }}```@@ -149,14 +149,14 @@ help translators to translate an entire sentence. To translate ablock, Jinja2 uses the [trans][] tag. So rather than writingsomething ugly and confusing for translators like this:-```+```jinja# Don't do this!{{ _("This string will have") }} {{ value }} {{ _("inside") }}```You can instead use:-```+```jinja{% trans %}This string will have {{ value }} inside.{% endtrans %}```@@ -165,7 +165,7 @@ You can instead use:A string in Python can be marked for translation using the `_()` function,which can be imported as follows:-```+```pythonfrom django.utils.translation import gettext as _```@@ -174,7 +174,7 @@ ensure this, the error message passed to `JsonableError`should always be a literal string enclosed by `_()`function, e.g.:-```+```pythonJsonableError(_('English text'))```@@ -256,13 +256,13 @@ $t_html(For translations in Handlebars templates we also use FormatJS, through twoHandlebars [helpers][] that Zulip registers. The syntax for simple strings is:-```+```html+handlebars{{t 'English text' }}```If you are passing a translated string to a Handlebars partial, you can use:-```+```html+handlebars{{> template_namevariable_name=(t 'English text')}}@@ -270,7 +270,8 @@ If you are passing a translated string to a Handlebars partial, you can use:The syntax for block strings or strings containing variables is:-```+<!-- The html+handlebars lexer fails to lex the single braces. -->+```text{{#tr}}Block of English text.{{/tr}}@@ -297,7 +298,7 @@ Restrictions on including HTML tags in translated strings are the sameas in JavaScript. You can insert more complex markup using a localcustom HTML tag like this:-```+```html+handlebars{{#tr}}<b>HTML</b> linking to the <z-link>login page</z-link>{{#*inline "z-link"}}<a href="/login/">{{> @partial-block}}</a>{{/inline}}@@ -318,7 +319,7 @@ file, located at `~/.transifexrc`.You can find details on how to set it up [here][transifexrc], but it shouldlook similar to this (with your credentials):-```+```ini[https://www.transifex.com]username = usertoken =diff --git a/docs/translating/translating.md b/docs/translating/translating.mdindex 60be15a766a..85ef92badd9 100644--- a/docs/translating/translating.md+++ b/docs/translating/translating.md@@ -147,7 +147,7 @@ There are a few ways to see your translations in the Zulip UI:you can pass the `Accept-Language` header; here is some sample code totest `Accept-Language` header using Python and `requests`:- ```+ ```pythonimport requestsheaders = {"Accept-Language": "de"}response = requests.get("http://localhost:9991/login/", headers=headers)diff --git a/docs/tutorials/life-of-a-request.md b/docs/tutorials/life-of-a-request.mdindex 96a56c35017..a54f00c55e9 100644--- a/docs/tutorials/life-of-a-request.md+++ b/docs/tutorials/life-of-a-request.md@@ -29,7 +29,7 @@ File not found errors (404) are served using a Django URL, so that wecan use configuration variables (like whether the user is logged in)in the 404 error page.-```+```nginxlocation /static/ {alias /home/zulip/prod-static/;# Set a nonexistent path, so we just serve the nice Django 404 page.@@ -61,10 +61,7 @@ in[the directory structure doc](../overview/directory-structure.md).The main Zulip Django app is `zerver`. The routes are found in-```-zproject/urls.py-zproject/legacy_urls.py-```+`zproject/urls.py` and `zproject/legacy_urls.py`.There are HTML-serving, REST API, legacy, and webhook url patterns. Wewill look at how each of these types of requests are handled, and focus@@ -140,9 +137,11 @@ yields a response with this HTTP header:We can see this reflected in [zproject/urls.py](https://github.com/zulip/zulip/blob/master/zproject/urls.py):- rest_path('users',- GET=get_members_backend,- PUT=create_user_backend),+```python+rest_path('users',+ GET=get_members_backend,+ PUT=create_user_backend),+```In this way, the API is partially self-documenting.@@ -175,7 +174,7 @@ the request, and then figure out which view to show from that.In our example,-```+```pythonGET=get_members_backend,PUT=create_user_backend```@@ -195,7 +194,9 @@ This is covered in good detail in the [writing views doc](writing-views.md).Our API works on JSON requests and responses. Every API endpoint should`raise JsonableError` in the case of an error, which gives a JSON string:-`{'result': 'error', 'msg': <some error message>, 'code': 'BAD_REQUEST'}`+```json+{"result": "error", "msg": "<some error message>", "code": "BAD_REQUEST"}+```in a[HTTP response](https://docs.djangoproject.com/en/1.8/ref/request-response/)@@ -203,11 +204,13 @@ with a content type of 'application/json'.To pass back data from the server to the calling client, in the event ofa successfully handled request, we use-`json_success(data=<some python object which can be converted to a JSON string>`.+`json_success(data=<some python object which can be converted to a JSON string>)`.This will result in a JSON string:-`{'result': 'success', 'msg': '', 'data'='{'var_name1': 'var_value1', 'var_name2': 'var_value2'...}`+```json+{"result": "success", "msg": "", "data": {"var_name1": "var_value1", "var_name2": "var_value2"}}+```with a HTTP 200 status and a content type of 'application/json'.diff --git a/docs/tutorials/new-feature-tutorial.md b/docs/tutorials/new-feature-tutorial.mdindex 02b8e36ac44..16347cf7388 100644--- a/docs/tutorials/new-feature-tutorial.md+++ b/docs/tutorials/new-feature-tutorial.md@@ -68,7 +68,7 @@ organization in Zulip). The following files are involved in the process:**Create and run the migration:** To create and apply a migration, run thefollowing commands:-```+```bash./manage.py makemigrations./manage.py migrate```@@ -168,14 +168,13 @@ boolean field, `mandatory_topics`, to the Realm model in`zerver/models.py`.``` diff+ # zerver/models.py-# zerver/models.py--class Realm(models.Model):- # ...- emails_restricted_to_domains: bool = models.BooleanField(default=True)- invite_required: bool = models.BooleanField(default=False)-+ mandatory_topics: bool = models.BooleanField(default=False)+ class Realm(models.Model):+ # ...+ emails_restricted_to_domains: bool = models.BooleanField(default=True)+ invite_required: bool = models.BooleanField(default=False)++ mandatory_topics: bool = models.BooleanField(default=False)```The Realm model also contains an attribute, `property_types`, which@@ -186,18 +185,17 @@ is the field's type. Add the new field to the `property_types`dictionary.``` diff+ # zerver/models.py-# zerver/models.py--class Realm(models.Model)- # ...- # Define the types of the various automatically managed properties- property_types = dict(- add_custom_emoji_policy=int,- allow_edit_history=bool,- # ...-+ mandatory_topics=bool,- # ...+ class Realm(models.Model)+ # ...+ # Define the types of the various automatically managed properties+ property_types = dict(+ add_custom_emoji_policy=int,+ allow_edit_history=bool,+ # ...++ mandatory_topics=bool,+ # ...```**The majority of realm settings can be included in@@ -231,7 +229,7 @@ is helpful.Apply the migration using Django's `migrate` command: `./manage.py migrate`.Output:-```+```consoleshell $ ./manage.py migrateOperations to perform:Synchronize unmigrated apps: staticfiles, analytics, pipeline@@ -291,50 +289,54 @@ argument can be a single user (if the setting is a personal one, liketime display format), members in a particular stream only or allactive users in a realm.- # zerver/lib/actions.py-- def do_set_realm_property(- realm: Realm, name: str, value: Any, *, acting_user: Optional[UserProfile]- ) -> None:- """Takes in a realm object, the name of an attribute to update, the- value to update and and the user who initiated the update.- """- property_type = Realm.property_types[name]- assert isinstance(value, property_type), (- 'Cannot update %s: %s is not an instance of %s' % (- name, value, property_type,))-- setattr(realm, name, value)- realm.save(update_fields=[name])- event = dict(- type='realm',- op='update',- property=name,- value=value,- )- send_event(realm, event, active_user_ids(realm))+```python+# zerver/lib/actions.py++def do_set_realm_property(+ realm: Realm, name: str, value: Any, *, acting_user: Optional[UserProfile]+) -> None:+ """Takes in a realm object, the name of an attribute to update, the+ value to update and and the user who initiated the update.+ """+ property_type = Realm.property_types[name]+ assert isinstance(value, property_type), (+ 'Cannot update %s: %s is not an instance of %s' % (+ name, value, property_type,))++ setattr(realm, name, value)+ realm.save(update_fields=[name])+ event = dict(+ type='realm',+ op='update',+ property=name,+ value=value,+ )+ send_event(realm, event, active_user_ids(realm))+```If the new realm property being added does not fit into the`property_types` framework (such as the `authentication_methods`field), you'll need to create a new function to explicitly update thisfield and send an event. For example:- # zerver/lib/actions.py-- def do_set_realm_authentication_methods(- realm: Realm, authentication_methods: Dict[str, bool], *, acting_user: Optional[UserProfile]- ) -> None:- for key, value in list(authentication_methods.items()):- index = getattr(realm.authentication_methods, key).number- realm.authentication_methods.set_bit(index, int(value))- realm.save(update_fields=['authentication_methods'])- event = dict(- type="realm",- op="update_dict",- property='default',- data=dict(authentication_methods=realm.authentication_methods_dict())- )- send_event(realm, event, active_user_ids(realm))+```python+# zerver/lib/actions.py++def do_set_realm_authentication_methods(+ realm: Realm, authentication_methods: Dict[str, bool], *, acting_user: Optional[UserProfile]+) -> None:+ for key, value in list(authentication_methods.items()):+ index = getattr(realm.authentication_methods, key).number+ realm.authentication_methods.set_bit(index, int(value))+ realm.save(update_fields=['authentication_methods'])+ event = dict(+ type="realm",+ op="update_dict",+ property='default',+ data=dict(authentication_methods=realm.authentication_methods_dict())+ )+ send_event(realm, event, active_user_ids(realm))+```### Update application state@@ -351,27 +353,29 @@ apps). The `apply_event` function in `zerver/lib/events.py` is important formaking sure the `state` is always correct, even in the event of rarerace conditions.- # zerver/lib/events.py+```python+# zerver/lib/events.py- def fetch_initial_state_data(user_profile, event_types, queue_id, include_subscribers=True):- # ...- if want('realm'):+def fetch_initial_state_data(user_profile, event_types, queue_id, include_subscribers=True):+ # ...+ if want('realm'):for property_name in Realm.property_types:state['realm_' + property_name] = getattr(user_profile.realm, property_name)state['realm_authentication_methods'] = user_profile.realm.authentication_methods_dict()state['realm_allow_message_editing'] = user_profile.realm.allow_message_editing# ...- def apply_event- user_profile: UserProfile,- # ...- ) -> None:- for event in events:+def apply_event+ user_profile: UserProfile,+ # ...+) -> None:+ for event in events:# ...elif event['type'] == 'realm':field = 'realm_' + event['property']state[field] = event['value']# ...+```If your new realm property fits the `property_types`framework, you don't need to change `fetch_initial_state_data` or@@ -380,14 +384,16 @@ property that is handled separately, you will need to explicitly addthe property to the `state` dictionary in the `fetch_initial_state_data`function. E.g., for `authentication_methods`:- # zerver/lib/events.py+```python+# zerver/lib/events.py- def fetch_initial_state_data(user_profile, event_types, queue_id, include_subscribers=True):- # ...- if want('realm'):- # ...- state['realm_authentication_methods'] = user_profile.realm.authentication_methods_dict()- # ...+def fetch_initial_state_data(user_profile, event_types, queue_id, include_subscribers=True):+ # ...+ if want('realm'):+ # ...+ state['realm_authentication_methods'] = user_profile.realm.authentication_methods_dict()+ # ...+```For this setting, one won't need to change `apply_event` since itsdefault code for `realm` event types handles this case correctly, but@@ -409,8 +415,7 @@ function in `zerver/views/realm.py` (and add the appropriate mypy typeannotation).``` diff--# zerver/views/realm.py+ # zerver/views/realm.pydef update_realm(request: HttpRequest,@@ -430,15 +435,17 @@ to `zerver/views/realm.py`.Text fields or other realm properties that need additional validationcan be handled at the beginning of `update_realm`.- # zerver/views/realm.py+```python+# zerver/views/realm.py- # Additional validation/error checking beyond types go here, so- # the entire request can succeed or fail atomically.- if default_language is not None and default_language not in get_available_language_codes():- raise JsonableError(_("Invalid language '%s'" % (default_language,)))- if description is not None and len(description) > 100:- raise JsonableError(_("Realm description cannot exceed 100 characters."))- # ...+# Additional validation/error checking beyond types go here, so+# the entire request can succeed or fail atomically.+if default_language is not None and default_language not in get_available_language_codes():+ raise JsonableError(_("Invalid language '%s'" % (default_language,)))+if description is not None and len(description) > 100:+ raise JsonableError(_("Realm description cannot exceed 100 characters."))+# ...+```The code in `update_realm` loops through the `property_types` dictionaryand calls `do_set_realm_property` on any property to be updated from@@ -449,20 +456,22 @@ to call the function you wrote in `actions.py` that updates the databasewith the new value. E.g., for `authentication_methods`, we created`do_set_realm_authentication_methods`, which we will call here:- # zerver/views/realm.py+```python+# zerver/views/realm.py- # import do_set_realm_authentication_methods from actions.py- from zerver.lib.actions import (- do_set_realm_message_editing,- do_set_realm_authentication_methods,- # ...- )- # ...- # ...- if authentication_methods is not None and realm.authentication_methods_dict() != authentication_methods:- do_set_realm_authentication_methods(realm, authentication_methods, acting_user=user_profile)- data['authentication_methods'] = authentication_methods+# import do_set_realm_authentication_methods from actions.py+from zerver.lib.actions import (+ do_set_realm_message_editing,+ do_set_realm_authentication_methods,# ...+)+# ...+# ...+if authentication_methods is not None and realm.authentication_methods_dict() != authentication_methods:+ do_set_realm_authentication_methods(realm, authentication_methods, acting_user=user_profile)+ data['authentication_methods'] = authentication_methods+# ...+```This completes the backend implementation. A great next step is towrite automated backend tests for your new feature.@@ -508,18 +517,17 @@ template.Then add the new form control in `static/js/admin.js`.``` diff--// static/js/admin.js--function _setup_page() {- var options = {- realm_name: page_params.realm_name,- realm_description: page_params.realm_description,- realm_emails_restricted_to_domains: page_params.realm_emails_restricted_to_domains,- realm_invite_required: page_params.realm_invite_required,- // ...-+ realm_mandatory_topics: page_params.mandatory_topics,- // ...+ // static/js/admin.js++ function _setup_page() {+ var options = {+ realm_name: page_params.realm_name,+ realm_description: page_params.realm_description,+ realm_emails_restricted_to_domains: page_params.realm_emails_restricted_to_domains,+ realm_invite_required: page_params.realm_invite_required,+ // ...++ realm_mandatory_topics: page_params.mandatory_topics,+ // ...```The JavaScript code for organization settings and permissions can be found in@@ -582,20 +590,19 @@ setting has changed, your function should be referenced in the`settings_emoji.update_custom_emoji_ui`.``` diff--// static/js/server_events_dispatch.js--function dispatch_normal_event(event) {- switch (event.type) {- // ...- case 'realm':- var realm_settings = {- add_custom_emoji_policy: settings_emoji.update_custom_emoji_ui,- allow_edit_history: noop,- // ...-+ mandatory_topics: noop,- // ...- };+ // static/js/server_events_dispatch.js++ function dispatch_normal_event(event) {+ switch (event.type) {+ // ...+ case 'realm':+ var realm_settings = {+ add_custom_emoji_policy: settings_emoji.update_custom_emoji_ui,+ allow_edit_history: noop,+ // ...++ mandatory_topics: noop,+ // ...+ };```Checkboxes and other common input elements handle the UI updates@@ -638,12 +645,14 @@ At the minimum, if you created a new function to update UI in`frontend_tests/node_tests/dispatch.js`. Add the name of the UIfunction you created to the following object with `noop` as the value:- # frontend_tests/node_tests/dispatch.js+```js+// frontend_tests/node_tests/dispatch.js- set_global('settings_org', {- update_email_change_display: noop,- update_name_change_display: noop,- });+set_global('settings_org', {+ update_email_change_display: noop,+ update_name_change_display: noop,+});+```Beyond that, you should add any applicable tests that verify thebehavior of the setting you just created.diff --git a/docs/tutorials/shell-tips.md b/docs/tutorials/shell-tips.mdindex f012c3d0b58..6b3b44b4a09 100644--- a/docs/tutorials/shell-tips.md+++ b/docs/tutorials/shell-tips.md@@ -44,7 +44,7 @@ abbreviation for your home directory (`/home/YOUR_USERNAME` most of the times).That's why the following is exactly the same, if the user running it is`john`:-```+```console$ cd ~$ cd /home/john```@@ -58,7 +58,7 @@ directory, instead of writing the whole path.Imagine you have a file called `ideas.txt` inside `/home/john/notes/`, andyou want to edit it using `nano`. You could use:-```+```console$ nano /home/john/notes/ideas.txt```@@ -69,7 +69,7 @@ That's why it's very useful to change the path where you are currentlylocated (usually known as **working directory**). To do that, you use `cd`(**c**hange **d**irectory):-```+```console$ cd /home/john/notes/~/notes$ nano ideas.txt```@@ -99,7 +99,7 @@ In case you were wondering, the name `sudo` comes from **s**uper **u**serSome characters cannot be used directly in the shell, because they have aspecial meaning. Consider the following example:-```+```console$ echo "He said hello"He said hello```@@ -118,7 +118,7 @@ before it.Returning to our example:-```+```console$ echo "He said \"hello\""He said "hello"```@@ -138,7 +138,7 @@ the shell provides two different separators:- **Semicolon `;`**: runs a command, and once it has finished, runs the nextone:- ```+ ```console$ echo "Hello"; echo "World!"HelloWorld!@@ -147,7 +147,7 @@ the shell provides two different separators:- **Double ampersand `&&`**: runs a command, and **only if** it finishedwithout errors, it proceeds with the next one:- ```+ ```console$ qwfvijwe && echo "Hello"qwfvijwe: command not found```@@ -158,7 +158,7 @@ the shell provides two different separators:When using an incorrect command with a semicolon, the `Hello` will stillbe printed:- ```+ ```console$ qwfvijwe; echo "Hello"qwfvijwe: command not foundHello@@ -176,7 +176,7 @@ shell "wait, there's more on the next line".This is an example, taken from the docs on how to install the Zulip developmentenvironment:-```+```bashsudo apt-get -y purge vagrant && \curl -fLO https://releases.hashicorp.com/vagrant/2.0.2/vagrant_2.0.2_x86_64.deb && \sudo dpkg -i vagrant*.deb && \@@ -204,7 +204,7 @@ Most commands need additional data to work, like a path or a file. That extrainformation is called an **argument**, and it's specified after the name of thecommand, like this:-```+```console$ cd /home/john/notes```@@ -221,7 +221,7 @@ different meanings.Sometimes, a command can accept arguments indicated with dashes. Here's anotherexample of arguments usage:-```+```console$ nano -C /home/john/backups --mouse todo.txt```@@ -245,7 +245,7 @@ Note that the `todo.txt` is the file we want to open! It has nothing to do withthe previous argument. This will probably clarify it (taken from `nano`'shelp):-```+```consoleUsage: nano [OPTIONS] [FILE]...```@@ -263,13 +263,13 @@ them.That's why you may have seen cases, in the Zulip codebase orelsewhere, when some Python scripts are called with `python`:-```+```console$ python my_program.py```While other times, `python` isn't used:-```+```console$ ./my_program.py```@@ -281,7 +281,7 @@ The note telling the OS how to interpret the file goes on the file'svery first line, and it's called a **shebang**. In our Python scripts,it looks like this:-```+```python#!/usr/bin/env python3```@@ -294,7 +294,7 @@ added as a command-line argument. So, returning to our example with`my_program.py`, when you run `./my_program.py`, what happens underthe hood is equivalent to:-```+```console$ /usr/bin/env python3 ./my_program.py```diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.pyindex 9d6d3b7e763..27b8fc0f325 100644--- a/tools/linter_lib/custom_check.py+++ b/tools/linter_lib/custom_check.py@@ -97,6 +97,9 @@ markdown_whitespace_rules: List["Rule"] = ["pattern": "^#+[A-Za-z0-9]","strip": "\n","description": "Missing space after # in heading",+ "exclude_line": {+ ("docs/subsystems/hotspots.md", "#hotspot_new_hotspot_name_icon {"),+ },"good_lines": ["### some heading", "# another heading"],"bad_lines": ["###some heading", "#another heading"],},