Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.

Commit db59c98

Browse files
author
amarcu
committed
License and readme
0 parents  commit db59c98

File tree

4 files changed

+125
-0
lines changed

4 files changed

+125
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor/

CONTRIBUTING.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Contributing to Hack Codegen
2+
We want to make contributing to this project as easy and transparent as
3+
possible.
4+
5+
## Our Development Process
6+
We will continue developing Hack Codegen in Facebook and synchronizing
7+
periodically our internal repository with this github repository.
8+
We will also accept pull requests in this repository and incorporate
9+
them in our internal repository.
10+
11+
## Pull Requests
12+
We actively welcome your pull requests.
13+
1. Fork the repo and create your branch from `master`.
14+
2. If you've added code that should be tested, add tests
15+
3. Ensure the test suite passes and the example still work
16+
4. If you haven't already, complete the Contributor License Agreement ("CLA").
17+
18+
## Contributor License Agreement ("CLA")
19+
In order to accept your pull request, we need you to submit a CLA. You only need
20+
to do this once to work on any of Facebook's open source projects.
21+
22+
Complete your CLA here: <https://code.facebook.com/cla>
23+
24+
## Issues
25+
We use GitHub issues to track public bugs. Please ensure your description is
26+
clear and has sufficient instructions to be able to reproduce the issue.
27+
28+
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
29+
disclosure of security bugs. In those cases, please go through the process
30+
outlined on that page and do not file a public issue.
31+
32+
## Coding Style
33+
* 2 spaces for indentation rather than tabs
34+
* 80 character line length
35+
* Please be consistent with the coding style
36+
37+
## License
38+
By contributing Hack Codegen, you agree that your contributions will be licensed
39+
under its BSD license.

LICENSE

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
BSD License
2+
3+
For Hack Codegen software
4+
5+
Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice, this
11+
list of conditions and the following disclaimer.
12+
13+
* Redistributions in binary form must reproduce the above copyright notice,
14+
this list of conditions and the following disclaimer in the documentation
15+
and/or other materials provided with the distribution.
16+
17+
* Neither the name Facebook nor the names of its contributors may be used to
18+
endorse or promote products derived from this software without specific
19+
prior written permission.
20+
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
25+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Hack Codegen
2+
Hack Codegen is a library for easily generating Hack code and writing it
3+
into signed files that prevent undesired modifications.
4+
The idea behind writing code that writes code is to raise the level of
5+
abstraction and reduce coupling. You can use your own way of describing
6+
a problem and generate the corresponding code. E.g. see examples/dorm.
7+
In this example, we use a schema to describe the structure of the data,
8+
and we use Hack Codegen to write the matching code.
9+
10+
11+
## Examples
12+
The DORM example shows how to use the different aspects of the code
13+
generation in a simplified real-life example.
14+
The included tests also exemplify the usage of the different components.
15+
16+
17+
## Requirements
18+
Hack Codegen requires:
19+
* HHVM
20+
* Composer
21+
22+
## Installing Hack Codegen
23+
To install this package via composer, just add the package to require and start using it.
24+
25+
```json
26+
{
27+
"require": {
28+
"facebook/hackcodegen": "*"
29+
}
30+
}
31+
```
32+
33+
## Usage
34+
Include the autoload file generated by composer and you are set. For example:
35+
36+
```php
37+
require 'vendor/autoload.php';
38+
39+
echo codegen_file('HelloWorld.php')
40+
->addClass(
41+
codegen_class('HelloWorld')
42+
->addMethod(
43+
codegen_method('sayHi')
44+
->setBody('echo "hello world\n";')
45+
)
46+
)->save();
47+
48+
```
49+
50+
## Configuration
51+
You can configure some options such as the maximum line width, spacing and
52+
headers by editing the file src/HackCodegenConfig.php
53+
54+
## License
55+
Hack Codegen is BSD-licensed. We also provide an additional patent grant.

0 commit comments

Comments
 (0)