Skip to content

Commit a58af98

Browse files
Wilfredgithub-actions[bot]
authored andcommitted
Update guides/hack from HHVM repository
1 parent 9c52556 commit a58af98

File tree

5 files changed

+98
-157
lines changed

5 files changed

+98
-157
lines changed

guides/hack/15-asynchronous-operations/07-awaitables.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
# Awaitables
22

3-
<!-- ```yamlmeta
4-
{
5-
"namespace": "HH\\Asio"
6-
}
7-
``` -->
8-
93
An *awaitable* is the key construct in `async` code. An awaitable is a first-class object that represents a possibly asynchronous
104
operation that may or may not have completed. We `await` the awaitable until the operation has completed.
115

Lines changed: 16 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,35 @@
11
# Introduction
22

3-
:::caution
4-
5-
The below instructions are out of date. The documentation site is now moved over to [Docusaurus](https://docusaurus.io/).
6-
7-
:::
8-
93
## Prerequisites
104

11-
You'll need HHVM
12-
(see [installation instructions](/docs/hhvm/installation/introduction))
13-
installed on your local machine, and the version must have the same major
14-
and minor (e.g. `4.123`) as the version specification in the `composer.json`
15-
file.
16-
17-
You'll also need a checkout of the source code for this site.
18-
19-
```
20-
$ git clone [email protected]:hhvm/user-documentation.git
21-
```
22-
23-
## Composer Dependencies
24-
25-
We use Composer to manage our PHP library dependencies and to autoload classes.
26-
Composer is written in PHP, so you need PHP installed.
27-
28-
```
29-
# Ubuntu example, your environment may differ.
30-
$ apt-get install php-cli
31-
```
32-
33-
You can now follow the instructions on [the Composer website](https://getcomposer.org/) to install it.
34-
35-
Once you've installed `composer.phar`, you can install the website dependencies into `vendor/` and create the autoload map.
36-
37-
```
38-
$ cd user-documentation
39-
user-documentation$ php /path/to/composer.phar install
40-
```
5+
This documentation site is built with [Docusaurus](https://docusaurus.io/). To run the site locally for development and testing, ensure [Node.js](https://nodejs.org/en/) (v20.0 or above) and [Yarn](https://yarnpkg.com/) are installed.
416

42-
### Updating Dependencies
7+
<FbInfo>
8+
As a Meta employee, to run the site on an **On Demand** or a **Dev Server**, follow the instructions on the [Static Docs prerequisites page](https://www.internalfb.com/intern/staticdocs/staticdocs/docs/setup/2-prequisites/), which also describes how to set up proxying. Any updates to the documentation in the repository will be reflected on the [internal Static Docs](https://www.internalfb.com/intern/staticdocs/hack/) site through [automated periodic deployments](https://www.internalfb.com/intern/staticdocs/staticdocs/docs/setup/4-configerator/#periodic-deployment)
9+
</FbInfo>
4310

44-
We require that this whole repository has no type errors.
11+
## Running locally
4512

46-
```
47-
$ hh_client
48-
No errors!
49-
```
13+
1. Navigate to the `website/` directory and run `yarn install` to install all the required dependencies.
5014

51-
If you are seeing errors in `vendor/`, re-run the composer install command to ensure that all dependencies are up to date.
15+
2. Next, to run the site locally, run `yarn start`.
5216

53-
**NOTE**: If you add, delete or rename a class in the primary source tree `src/`, you should run `php composer.phar dump-autoload` in order to make the autoload maps refresh correctly; otherwise you will get class not found exceptions.
17+
3. This will start a local server on port 3000. You can view the site at [http://localhost:3000](http://localhost:3000).
5418

55-
## Running A Local Instance
19+
<FbInfo>
20+
The documentation site allows for creation of internal paragraphs/blocks that are only visible to Meta employees. To view these parts of the documentation, you must be on a Meta network or VPN. For local testing, running `yarn start-fb` will switch the local server into a mode that will allow you to view the internal-only parts of the documentation.
21+
</FbInfo>
5622

57-
Generate `public/` by running the build script. This script will only
58-
run the steps related to your changes, so the first run will be slower
59-
than later runs.
23+
Whilst `yarn start` is running, any changes made to the documentation will be published to the local instance automatically, allowing for a fast feedback loop as you make updates.
6024

61-
```
62-
$ hhvm bin/build.php
63-
```
25+
## Running an old version
6426

65-
HHVM has a built-in webserver, so it can serve the entire website.
66-
67-
```
68-
$ cd public
69-
$ hhvm -m server -p 8080 -c ../hhvm.dev.ini
70-
```
71-
72-
You can now see your local instance by visiting [http://localhost:8080](http://localhost:8080).
73-
74-
When you make changes, you'll need to run `build.php` again. You can
75-
leave HHVM serving the site, and it will pick up the changes
76-
automatically.
77-
78-
## Running An Old Instance
79-
80-
If you want to see old versions of the docs, we provide [regular Docker
81-
images of this site](https://ghcr.io/hhvm/user-documentation) (previously
27+
If you want to see old versions of the docs (from before our migration to Docusaurus in 2025), we provided [regular Docker images of the old documentation site](https://ghcr.io/hhvm/user-documentation) on GHCR (previously
8228
on [Docker Hub](https://hub.docker.com/r/hhvm/user-documentation/tags)).
83-
This is not suitable for development, but is useful if you're working with
84-
an old HHVM/Hack version.
85-
8629

30+
These images are not suitable for development, but are useful if you are working with
31+
an old HHVM/Hack version.
8732

8833
1. Install [Docker](https://docs.docker.com/engine/installation/).
8934
2. Start a container with: `docker run -p 8080:80 -d ghcr.io/hhvm/user-documentation`.
9035
3. You can then access a local copy of the documentation at [http://localhost:8080](http://localhost:8080).
91-
92-
## Running A Production Instance
93-
94-
Running a production instance is very similar to a development
95-
instance.
96-
97-
Configure a webserver and HHVM to serve the `public/`
98-
directory. Ensure that all requests that don't match a local file are
99-
served by `index.php`.

guides/hack/90-contributing/06-writing-content.md

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ The website has three content sections:
1313
examples](https://github.com/hhvm/user-documentation/tree/main/api-examples)
1414
for each API
1515

16-
## File Naming Conventions
16+
<FbInfo>
17+
Internally, the sources for all of the Hack, HHVM, HSL and API guides are stored under the same directory, `fbcode/hphp/hack/manual/`. The Hack guides are set up to automatically mirror those on `hhvm/user-documentation`
18+
</FbInfo>
19+
20+
## File naming conventions
1721

1822
A guide is a folder with a numeric prefix:
1923

@@ -26,59 +30,47 @@ $ ls guides/hack/
2630

2731
These numbers are used to control the ordering of guides on the
2832
website, and are not shown in the UI. They do not need to be
29-
sequential: there can be gaps.
33+
sequential; there can be gaps.
3034

31-
Within each folder, there are markdown files (written in [GitHub
32-
flavored markdown](https://github.github.com/gfm/)), a `foo-category.txt` (used
33-
for grouping on the home page) and a `foo-summary.txt` (shown as a subheading on
34-
the home page).
35+
Within each folder, there are Markdown files (written in [Markdown](https://docusaurus.io/docs/markdown-features)).
3536

3637
```
37-
$ ls guides/hack/getting-started/
38-
01-getting-started.md
38+
$ ls guides/hack/01-getting-started/
39+
01-quick-start.md
3940
02-tools.md
40-
getting-started-category.txt
41-
getting-started-summary.txt
4241
```
4342

4443
Pages use the same numbering system to control their order within a
4544
guide.
4645

47-
## Writing Conventions
46+
## Writing conventions
4847

4948
Guides are written in a relatively informal tone, addressing the
5049
reader as "you". Assume the reader has some programming knowledge but
5150
no familiarity with Hack.
5251

5352
Each page should have a clear purpose, starting with a short
54-
description of the concept it's describing. Examples should always be
53+
description of the concept it is describing. Examples should always be
5554
provided, preferably under 15 lines.
5655

5756
We assume the reader has a relatively recent version of
5857
HHVM. References to very old features will be removed, but we provide
5958
[Docker images of historical site
60-
versions](/docs/hack/contributing/introduction#running-an-old-instance) if
61-
needed.
59+
versions](/docs/hack/contributing/introduction#running-an-old-version) if
60+
needed (from before we migrated to Docusaurus in 2025).
6261

63-
It's not necessary to document all the incorrect ways a feature can be
62+
It is not necessary to document all the incorrect ways a feature can be
6463
used. Content should focus on correct usage, and users can rely on the
65-
Hack type checker to tell them when they've done something wrong.
64+
Hack type checker to tell them when they have done something wrong.
6665

6766
## Links
6867

69-
Internal links should be absolute paths without a domain,
68+
Internal links should be **absolute paths** without a domain,
7069
e.g. `/hack/contributing/introduction`.
7170

72-
Image paths should be relative to `public`,
73-
e.g. `/images/imagename.png`.
74-
75-
When removing or renaming pages, set up a redirect from the old
76-
URL. See [`Guides::getGuidePageRedirects`](https://github.com/hhvm/user-documentation/blob/9fd2aaeb60a236072ef99735a9114ec54d96da2c/src/Guides.php#L56).
77-
78-
## Styling
71+
Image paths should be relative to `static`,
72+
e.g. `/img/imagename.png`.
7973

80-
We use [Sass](https://sass-lang.com/) to style the website, and the
81-
source files are in
82-
[sass/](https://github.com/hhvm/user-documentation/tree/main/sass).
74+
### Validating links
8375

84-
The CSS files are generated by the build script.
76+
To make sure all links between pages are valid, run `yarn docusaurus build`. This will check all links in the documentation and report any broken ones. It is generally advised to run this command before submitting a diff to ensure that all links are valid and that the changes do not break upstream publishing pipelines.

guides/hack/90-contributing/10-code-samples.md

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
# Code Samples
22

3-
All code samples are automatically type checked and executed, to ensure they're correct.
3+
All code samples are automatically type checked and executed, to ensure they are correct.
44

5-
## Basic Usage
5+
<FbInfo>
6+
7+
When working in `fbsource`, you can trigger this manually and check the results before submitting a diff (see more details on [the internal wiki](https://www.internalfb.com/wiki/Hack_Developer_Guide/Contributing_to_HHVM_Documentation/)):
8+
9+
```bash
10+
# Or wherever you have fbsource checked out
11+
$ cd ~/fbsource/fbcode
12+
$ buck2 run //hphp/hack/src/hh_manual:hh_manual extract hphp/hack/manual/hack/
13+
$ buck2 test //hphp/hack/test/typecheck:extracted_from_manual
14+
$ buck2 test //hphp/hack/test/typecheck:extracted_from_manual_error
15+
```
16+
17+
</FbInfo>
18+
19+
## Basic usage
620

721
Code samples require triple backticks, and a file name.
822

@@ -29,7 +43,7 @@ echo "Hello world!\n";
2943
```
3044
~~~
3145

32-
## Opting Out
46+
## Opting out
3347

3448
If you really need to write a code sample that isn't checked or executed, you can omit the file name. The code sample will be included in the docs without any checking.
3549

@@ -40,7 +54,16 @@ If you really need to write a code sample that isn't checked or executed, you ca
4054
```
4155
~~~
4256

43-
## Sharing Code
57+
To maintain syntax highlighting, you want to retain the language specifier.
58+
In those cases, you can also opt-out of extraction entirely using the `no-extract` specifier. E.g., the below example will be shown on the website with Hack syntax highlighting, but the type checker will ignore it when the validation job is run.
59+
60+
~~~
61+
```hack no-extract
62+
I am in the manual, but not checked.
63+
```
64+
~~~
65+
66+
## Sharing code
4467

4568
By default, each extracted example file has its own namespace based on the file name. This allows multiple examples to define the same class or function.
4669

@@ -115,7 +138,7 @@ This can also be more convenient because we can rely on the automatic
115138
boilerplate addition by the build script, instead of manually writing the
116139
`<<__EntryPoint>>` function header.
117140

118-
## Examples with Hack Errors
141+
## Examples with Hack errors
119142

120143
Examples that are expected to fail typechecking should use the `.type-errors`
121144
extension:
@@ -129,7 +152,7 @@ function missing_return_type() {}
129152
The build script will run the Hack typechecker and include its output in the
130153
rendered HTML (instead of HHVM runtime output).
131154

132-
## Supporting Files
155+
## Supporting files
133156

134157
An example code block may specify additional files to be extracted alongside the
135158
example code using the following format:
@@ -145,7 +168,7 @@ Your lucky number is: %d
145168
~~~
146169

147170
Supported extensions are inherited from the
148-
[HHVM test runner](https://github.com/facebook/hhvm/blob/master/hphp/test/README#file-layout):
171+
[HHVM test runner](https://github.com/facebook/hhvm/blob/master/hphp/test/README.md#file-layout):
149172

150173
- `.hhconfig` if the example requires specific *typechecker* flags
151174
(e.g. demonstrating a feature that is not yet enabled by default)
@@ -168,7 +191,7 @@ Supported extensions are inherited from the
168191
MySQL server running), otherwise print nothing
169192

170193

171-
## Testing Changes
194+
## Testing changes
172195

173196
We have a test suite to ensure consistency across the changes we make to the guides, API references, and examples.
174197

@@ -178,7 +201,7 @@ You can run it as follows:
178201
$ vendor/bin/hacktest tests/
179202
```
180203

181-
## Running the Examples
204+
## Running the examples
182205

183206
Nearly all of the code examples you see in the guides and API documentation are actual Hack or PHP source files that are embedded at site build time into the content itself.
184207

@@ -239,7 +262,7 @@ object(HH\Vector)#10 (5) {
239262
Time non lazy: 0.0096559524536133
240263
```
241264

242-
### Using the HHVM Test Runner
265+
### Using the HHVM test runner
243266

244267
Each example is structured to be run with the [HHVM test runner](https://github.com/facebook/hhvm/blob/master/hphp/test/README). We use the test runner internally to ensure that any changes made to HHVM do not cause a regression. The examples in the documentation here can be used for that purpose as well.
245268

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,42 @@
11
# Information Macros
22

3-
This website supports note, tip, caution, and danger macro messages.
4-
5-
## Note Message
6-
```yamlmeta
7-
{
8-
"note": [
9-
"This change was introduced in [HHVM 4.136](https://hhvm.com/blog/2021/11/19/hhvm-4.136.html)."
10-
]
11-
}
3+
This website supports `note`, `tip`, `caution`, and `danger` macro messages.
4+
5+
These can be added with [admonition](https://docusaurus.io/docs/markdown-features/admonitions) syntax:
6+
7+
```markdown
8+
:::note
9+
Your **content** goes here...
10+
:::
1211
```
1312

13+
## Note message
14+
15+
:::note
16+
This change was introduced in [HHVM 4.136](https://hhvm.com/blog/2021/11/19/hhvm-4.136.html).
17+
:::
18+
1419
The `noreturn` type can be upcasted to `dynamic`.
1520

16-
## Tip Message
17-
```yamlmeta
18-
{
19-
"tip": [
20-
"To start learning Hack, read our [Getting Started](/docs/hack/getting-started/getting-started) documentation!"
21-
]
22-
}
23-
```
21+
## Tip message
22+
23+
:::tip
24+
To start learning Hack, read our [Getting Started](/docs/hack/getting-started/quick-start) documentation!
25+
:::
26+
2427
Hack lets you write code quickly, while also having safety features built in, like static type checking.
2528

26-
## Caution Message
27-
```yamlmeta
28-
{
29-
"caution": [
30-
"We do not recommend using experimental features until they are formally announced and integrated into the main documentation set."
31-
]
32-
}
33-
```
29+
## Caution message
30+
31+
:::caution
32+
We do not recommend using experimental features until they are formally announced and integrated.
33+
:::
3434

3535
This website maintains documentation on Hack features that are in the *experimental* phase.
3636

37-
## Warning Message
38-
```yamlmeta
39-
{
40-
"danger": [
41-
"Use this method with caution. **If your query contains *ANY* unescaped input, you are putting your database at risk.**"
42-
]
43-
}
44-
```
37+
## Warning message
38+
:::danger
39+
Use this method with caution. **If your query contains *ANY* unescaped input, you are putting your database at risk.**
40+
:::
4541

4642
While inherently dangerous, you can use `AsyncMysqlConnection::query` to query a MySQL database client.

0 commit comments

Comments
 (0)